It’s good for os to get data from cache in memory. But if any data not found in the cache, it reads from hard disk. So it’s no problem to flush cache memory. This article has details about how to Flush Memory Cache on Linux Server.
Clear Linux Memory Buffer Cache:
There are three options available to flush cache of Linux memory. Use one of below as per your requirements.
What Is Sync;
means sync - synchronize data on disk with memory .
Free pagecache, dentries and inodes in cache memory in Linux machine
# sync; echo 3 > /proc/sys/vm/drop_caches
Free dentries and inodes use following command
# sync; echo 2 > /proc/sys/vm/drop_caches
Free pagecache only use following command
# sync; echo 1 > /proc/sys/vm/drop_caches
Schedule Cron to Flush Cache Regularly
This is very good idea if schedule following command in crontab to automatically flush cache on regular interval.
# crontab -l
#crontab -e
0 * * * * sync; echo 3 > /proc/sys/vm/drop_caches
# /etc/init.d/crond restart
The above cron will execute on every hour and flushes the cached memory on system.
Find Cache Memory uses in Linux
Use free command to find out cache memory uses by Linux system. Output of free command is below : Free -g
Last column is showing cached memory ( 14953 MB) by system. -m option is used for showing memory details in MB’s.
No comments:
Post a Comment