How to Clear Memory Cache on Linux

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:

[email protected]:~$ 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. Here, I show you how.

Open up your terminal and enter the following command to create a file called cacheclear.sh. Say for example, I create cacheclear.sh file in my /home directory:

[email protected]:~$ sudo vi /home/cacheclear.sh

Add the following lines to cacheclear.sh file:

#!/bin/sh 
sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

Save and exit the file. Now add this file to your crontab:

[email protected]:~$ sudo crontab -e

This command opens the current user cron file. If you want to set it to some other user, use the following command instead:

[email protected]:~$ sudo crontab -e -u username

Add the following line at the end:

0 * * * * /home/cacheclear.sh

Save and exit the file. Once you’re done, cron job will run this command every hour and will clear the system memory caches.

After testing with the above command, the sample results are shown in the below screen shots.

Before running the memory cache clearing script.

sk@sk: ~_012After running the memory cache clearing script.

sk@sk: ~_013As per the above outputs, the memory caches are reduced a bit.

  • Women normally wore Mary Janes, oxfords and button shoes.
    Some belts require purchasing them two inches larger than your actual waist size.

    In this way, you can easily save money on party and wedding dresses.
    You can fill them with small sized tops once you clear the interview.
    Make use of any bean bag chairs, flower pillows and 60’s memorabilia to decorate the room.
    Of course, if you’re interviewing for a job as a mechanic or
    where you’ll be outdoors most of the time, a suit may be a bit much.
    Starlight Amanda Bag by Kate Spade $225Kate Spade’s Starlight Amanda Bag has a silver soiree fabric ,14
    karat light gold hardware, and beige and white running, lightly through it.