Saturday, 23 February 2013

How to clear cache memory and set cron job on Linux server


To clear cache memory use  following command as user root in Terminal


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


Shell script for clear cache memory:  

# vim  /root/clearcache.sh

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

:wq

       Set the permission of ” /root/clearcache.sh” to 755
# chmod 755  /root/clearcache.sh


 Now edit crontab file

# crontab -e -u root

*/5   *   *   *   *   /root/clearcache.sh
:wq
        The above cron job will run every 5 minutes (*/5).


Now restart the cron service

#  /etc/init.d/crond  restart

How to list user crontab

# crontab -u username -l