[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:

1
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
1
2
#!/bin/sh
sync; echo 3 > /proc/sys/vm/drop_caches
  • Now, set the permission of script " /root/clearcache.sh" to 755
1
chmod 755 /root/clearcache.sh
  • Now edit crontab file
1
crontab -e
  • Enter following line to set cronjob for clearing cache every hour
1
0 * * * * /root/clearcache.sh
  • Restart crond service
1
/etc/init.d/crond restart

 If any feedback, queries are always welcome!

Share on Facebook2
Share on Google+5Tweet about this on TwitterShare on StumbleUpon82Share on LinkedIn0Share on Tumblr0Digg thisPin on Pinterest0Share on Reddit0Email this to someonePrint this page
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 #!/bin/sh sync; echo…

Review Overview

User Rating: 4.9 ( 1 votes)

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing knowledge!

4 comments

  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.

Leave a Reply

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

CAPTCHA