How to clear Cache & Buffer Memory on Linux? Linux

The Linux Page Cache (File System Cache) is used to make IO operations faster. Sometimes in certain circumstances as an administrator need to manually clear the cache. In this article we will share the steps on how to clear Cache and buffer memory.

The following steps are to clear Cached memory on Linux Servers

Use the free command to find the cache memory used by Linux OS

# free -m

The result for the above command is as follows –

total       used       free     shared    buffers     cached

Mem:     16050    15908   142          0     120      14953

-/+ buffers/cache:        834      15216

Swap:          0               0             0

The following command clears the Page Cache and Inodes

# sync; echo 3 > /proc/sys/vm/drop_caches

The following command clears the Inodes

# sync; echo 2 > /proc/sys/vm/drop_caches

The following command clears the Page Cache only

# sync; echo 1 > /proc/sys/vm/drop_caches

If you are required to clear the cache regularly, you can create a cron job that would run automatically

The following command creates the new cron job

# crontab -e

Add the following entry to the cron job file to execute every hour

0 * * * * sync; echo 3 > /proc/sys/vm/drop_caches 

At Velan, our server support engineers can help you to free cached memory on your Linux Server. For details, please visit https://www.velaninfo.com/mservices/managed-it-services

Credentials

Quick Connect With Us


    captcha
    reload