[How To] Clear cache memory & set cronjob on Linux

The cache memory in Linux systems is used to speed up the response. To learn more about cache, click here to visit the website.

Hopefully, after referring to the website the concept about cache in Linux should get clear.

If you still wish to free up the cache memory here you go.

To clear cache memory using command as user root:

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

 To set cronjob to clear cache memory at specific intervals:

  • Access server through shell as a root user.
  • Create a shell script say "clearcache.sh" under root partition and enter following contents
sync; echo 3 > /proc/sys/vm/drop_caches
  • Now, set the permission of script " /root/clearcache.sh" to 755
chmod 755 /root/clearcache.sh
  • Now edit crontab file
crontab -e
  • Enter following line to set cronjob for clearing cache every hour
0 * * * * /root/clearcache.sh
  • Restart crond service
/etc/init.d/crond restart

 If any feedback, queries are always welcome!

Share on Facebook2Share on Google+0Tweet about this on TwitterShare on StumbleUpon82Share on LinkedIn0Share on Tumblr0Pin on Pinterest0Email this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan

Loves Linux, Blogging, Traveling, Hiking and sharing Knowledge!


  1. Tnx, this helped me very much :).

    There is however a typo in your blog:

    chmod 755 /root/cleacrcache.sh

    There is an extra "c" in the file name!

  2. Hi,
    how can i enable it in android?

    • Abhijit Sandhan

      You will need a rooted phone to be a super user in the command line OR you can use clear cache applications like Clean Master present on Google Play Store.
      This should serve your purpose.

  3. I've added this directly in crontab -e as root

    0 * * * * /bin/sync; /bin/echo 3 > /proc/sys/vm/drop_caches

Leave a Reply

Your email address will not be published. Required fields are marked *