Author Topic: CentOS memory management  (Read 513 times)

saroop

  • Green Belt
  • *****
  • Posts: 352
  • Karma: +0/-0
CentOS memory management
« on: August 31, 2013, 10:54:53 AM »
Hi,



By default the Linux OS has a very efficient memory management process that should be freeing any cached memory on the machine that it is being run on. However when it comes to Cached memory the Linux OS may at times decide that the Cached memory is being used and is needed which can lead to memory related issues and ultimately rob your server of any potentially free memory. To combat this you can force the Linux OS to free up and stored Cached memory.

I. Connect via shell using a program such as Putty

II.  At the shell prompt type  crontab -e <enter>   as this will allow you to edit cron jobs for the root user.
   #  If you are not familiar with vi (linux editor) you press "i" to insert text and once done hit "esc" and type ":wq" to save the file.

III.  Scroll to the bottom of the cron file using the arrows key and enter the following line:

        0 * * * * /root/clearcache.sh

IV.  Create a file in '/root' called 'clearcache.sh' with the following content:

     #!/bin/sh
     sync; echo 3 > /proc/sys/vm/drop_caches


Once you have saved this file, the job is complete!
 
Every hour the cron job will run this command and clear any memory cache that has built up.


Regards
Saroop Datasoft