Loading
Rahmat S. Masror

MSCS, BBA, DIT, MCSE, CCNA, COM TIA+

IT Expert

Freelancer

IT Consultant

Server/Database Expert

3CX Advanced Certified Engineer

Rahmat S. Masror

MSCS, BBA, DIT, MCSE, CCNA, COM TIA+

IT Expert

Freelancer

IT Consultant

Server/Database Expert

3CX Advanced Certified Engineer

Blog Post

Clear cache memory and set cronjob on Linux server

June 1, 2013 CPANEL/DIRECTADMIN
Clear cache memory and set cronjob on Linux server

Below is the command to clear memory cache :-

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

Use the above command in cronjob using screipt

Login your server as a root user.

Then use it in script at “/root/cleacrcache.sh” and enter folllowing contents

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

Make  the permission of ” /root/cleacrcache.sh” to 755

[root@root~]#  chmod 755  /root/cleacrcache.sh

Run the cronjob using  crontab file as below :-

  [root@root~]#  crontab -e  OR
    [root@root~]# Vi /var/spool/cron/root

Enter below  cron  to set cronjob for clearing cache in every hour

   0 * * * * /root/clearcache.sh

Restart crond service

[root@root~]#  /etc/init.d/crond restart

Thats it you have done :)

Write a comment