Clearing PageCache, dentries and inodes in Linux

Like any other operating system, GNU/Linux has implemented a memory management efficiently and even more than that. But if any process is eating away your memory and you want to clear it, Linux provides a way to flush or clear ram cache. Use the following commands to clear PageCache, dentries and inodes, or PageCache, dentries and inodes.

To clear PageCache only.

[root@techrunnr ~]# sync; echo 1 /proc/sys/vm/drop_caches

To clear dentries and inodes.

[root@techrunnr ~]# sync; echo 2 /proc/sys/vm/drop_caches

Clear PageCache, dentries and inodes.

[root@techrunnr ~]# sync; echo 3 /proc/sys/vm/drop_caches

Steps to clear cache on a recurring schedule

Step 1: Create a script to clear PageCache, dentries and inodes.

[root@techrunnr ~]# vi /home/techrunnr/drop_caches.sh

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

Step: Edit crontab to run the script every 59 minutes.

[root@techrunnr ~]# vi /etc/crontab

*/59 * * * * techrunnr /home/techrunnr/drop_caches.sh

Verify the configuration
If you check cron log you can see the script is getting executing once in a hour on each 59th minute.

 

© 2018, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points
Categories: Linux

Prabhin Prabharkaran

He is Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!!

0 Comments

Leave a Reply

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.