Discuss IT and Design a variety of tutorials and design it. let's read that are useful to you. thank you for visiting my humble blog

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:
sk@sk:~$ 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:
sk@sk:~$ 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:
sk@sk:~$ 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:
sk@sk:~$ 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.
- See more at: http://www.unixmen.com/how-to-clear-memory-cache-on-linux-servers/#sthash.LJrOZvQE.dpuf
After running the memory cache clearing script.
As per the above outputs, the memory caches are reduced a bit. 

- See more at: http://www.unixmen.com/how-to-clear-memory-cache-on-linux-servers/#sthash.LJrOZvQE.dpuf
Share:

No comments:

Post a Comment

Popular Posts

Ismail Maha Putra. Powered by Blogger.
twitterfacebookgoogle pluslinkedinrss feedemail
SEO Reports for kendariit.blogspot.com

Followers

Blog Archive

Poll

Facebook Page Like

Translate

Get ThisWidget
Blogger Widgets

submit your site

http://smallseotools.com/google-pagerank-checker

Sonicrun

Google Search

Popular Posts

Tutorials, IT and Design

Blog Archive

Recent Posts

About Metro