Clear Memory Cache on Linux centos
![Linux yum Linux memory cache](https://sp-ao.shortpixel.ai/client/to_webp,q_glossy,ret_img,w_505,h_250/http://blog.eduguru.in/wp-content/uploads/2014/02/Linux.png)
By default, every Linux OS has an efficient memory management system used to clear the buffer cache periodically. You can manually free up the memory cache with the following simple command:
linux:~$ sudo sh -c “sync; echo 3 > /proc/sys/vm/drop_caches”
However, if you want to force the Linux OS to do clearing memory cache on a particular interval, just add the command to cron job.
There are three options available to flush cache of linux memeory. Use one of below as per your requirements.
More Options:
1. To free pagecache, dentries and inodes in cache memory
# sync; echo 3 > /proc/sys/vm/drop_caches
2. To free dentries and inodes use following command
# sync; echo 2 > /proc/sys/vm/drop_caches
3. To free pagecache only use following command
# sync; echo 1 > /proc/sys/vm/drop_caches
Setup Cron to Flush Cache Regularly
# crontab -e
0 * * * * sync; echo 3 > /proc/sys/vm/drop_caches