Cron Job Delete cache in a directory
Cron Job Delete cache in a directory
Hello,
I have a cache directory for my Opencart store theme that fills up pretty quickly that makes my website slow.
Inside Opencart admin iam able to clear cache, but i have to do that manually and many times i forget.
What i would need is a cron job to add in Vestacp to handle the job for me, if anyone can help with that would be appreciated.
the folder structure where cache are located "/public_html/journal-cache", i need cache deleted every 3 hours.
Thanks
I have a cache directory for my Opencart store theme that fills up pretty quickly that makes my website slow.
Inside Opencart admin iam able to clear cache, but i have to do that manually and many times i forget.
What i would need is a cron job to add in Vestacp to handle the job for me, if anyone can help with that would be appreciated.
the folder structure where cache are located "/public_html/journal-cache", i need cache deleted every 3 hours.
Thanks
Re: Cron Job Delete cache in a directory
You can use something like tmpwatch
path is something like /home/admin/web/domain.com/public_html/cachedir
This delete all your files so take care whit path and tmpwatch read documentation.
Code: Select all
0 1 * * * /usr/sbin/tmpwatch -m 3 /patch/to/dir
This delete all your files so take care whit path and tmpwatch read documentation.
Re: Cron Job Delete cache in a directory
Thanks for the info,skamasle wrote:You can use something like tmpwatch
path is something like /home/admin/web/domain.com/public_html/cachedirCode: Select all
0 1 * * * /usr/sbin/tmpwatch -m 3 /patch/to/dir
This delete all your files so take care whit path and tmpwatch read documentation.
i added the following line in command
Code: Select all
/usr/sbin/tmpwatch -m 3 /home/admin/web/domain.com/public_html/journal-cache
Code: Select all
"/bin/sh: /usr/sbin/tmpwatch: No such file or directory"
Re: Cron Job Delete cache in a directory
Install before use ;-)magzen wrote:but getting following errorCode: Select all
/usr/sbin/tmpwatch -m 3 /home/admin/web/domain.com/public_html/journal-cache
iam using centos, dont know if that matters.Code: Select all
"/bin/sh: /usr/sbin/tmpwatch: No such file or directory"
Code: Select all
yum install tmpwatch
Re: Cron Job Delete cache in a directory
You can try to use this line for cron:
find and rm are basic linux utilities.
Code: Select all
find /home/admin/web/domain.com/public_html/journal-cache/* -type f -mmin +180 -exec rm {} \;
Re: Cron Job Delete cache in a directory
Hiskurudo wrote:You can try to use this line for cron:find and rm are basic linux utilities.Code: Select all
find /home/admin/web/domain.com/public_html/journal-cache/* -type f -mmin +180 -exec rm {} \;
It was a while ago i was logged in to Vestacp forums so answer is little late :)
I did try the command a few days ago, but it resulted in a problem in the server, the Cron page stopped working and the command started generating lots of data, i was able to edit the Cron Job list using WinSCPand remove about 2.5MB generated data and the command, restarted the server but was still unable to enter the Cron page in Vestacp, and it still showed at the top 9 Cron Jobs instead of 8 which it was from the begining, do you have any idea how yo solve this and be able to enter the Cron page again without lots of loading and time out?
i started a thread on the following link
http://forum.vestacp.com/viewtopic.php? ... 238#p54238
Thanks
Re: Cron Job Delete cache in a directory
magzen, please stay in one topic, there is no need to duplicate question.