Friday, 13 December 2013

How to Clear Memory Cache on Linux Server

You may face difficulty when it comes to Cached memory that can lead to memory related issues and ultimately rob your server of any potentially free memory. Here you can force the OS to free up and stored Cached memory.

Use the following command to clear it.

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

If you wish you can include it in a file and run it a cron according to your requirement.

Save the above line in a file say clear_mem_cache.sh

    vi clear_mem_cache.sh

Include the following lines and save it.

    #!/bin/sh
    sync; echo 3 > /proc/sys/vm/drop_caches

Save it.

Set it a cron by opening the crontab editor using

    crontab -e

Add the following.

    0 * * * * /root/clear_mem_cache.sh

No comments:

Post a Comment