Flushing the Cached Memory
By default, Linux has a very efficient memory management process that should be freeing any cached memory on the server. However, the server may, at times, decide that the cached memory is needed but is being used which can lead to memory related issues.
You can use the following command to flush your cache memory
[email protected] [~]# echo 1 > /proc/sys/vm/drop_caches
Setup Cron to Remove Cached Memory
In order to remove cached memory on every hour the cron job will run this command and clear any memory cache that has built up. To create the script:
then paste the following entry:.
sync; echo 3 > /proc/sys/vm/drop_caches
the save and add this script in your cron job.
0 * * * * /root/clearcache.sh
Thats it. The cron’d script will remove cached memory automatically every hour.