Page 1 of 1

Cron Job Delete cache in a directory

Posted: Thu Apr 07, 2016 3:24 pm
by magzen
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

Re: Cron Job Delete cache in a directory

Posted: Thu Apr 07, 2016 6:52 pm
by skamasle
You can use something like tmpwatch

Code: Select all

0 1 * * * /usr/sbin/tmpwatch -m 3 /patch/to/dir
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.

Re: Cron Job Delete cache in a directory

Posted: Fri Apr 08, 2016 9:04 pm
by magzen
skamasle wrote:You can use something like tmpwatch

Code: Select all

0 1 * * * /usr/sbin/tmpwatch -m 3 /patch/to/dir
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.
Thanks for the info,

i added the following line in command

Code: Select all

/usr/sbin/tmpwatch -m 3 /home/admin/web/domain.com/public_html/journal-cache
but getting following error

Code: Select all

"/bin/sh: /usr/sbin/tmpwatch: No such file or directory"
iam using centos, dont know if that matters.

Re: Cron Job Delete cache in a directory

Posted: Mon Apr 25, 2016 2:29 pm
by skurudo
magzen wrote:

Code: Select all

/usr/sbin/tmpwatch -m 3 /home/admin/web/domain.com/public_html/journal-cache
but getting following error

Code: Select all

"/bin/sh: /usr/sbin/tmpwatch: No such file or directory"
iam using centos, dont know if that matters.
Install before use ;-)

Code: Select all

yum install tmpwatch

Re: Cron Job Delete cache in a directory

Posted: Mon Apr 25, 2016 2:32 pm
by skurudo
You can try to use this line for cron:

Code: Select all

find /home/admin/web/domain.com/public_html/journal-cache/* -type f -mmin +180 -exec rm {} \;
find and rm are basic linux utilities.

Re: Cron Job Delete cache in a directory

Posted: Tue Dec 13, 2016 8:52 am
by magzen
skurudo wrote:You can try to use this line for cron:

Code: Select all

find /home/admin/web/domain.com/public_html/journal-cache/* -type f -mmin +180 -exec rm {} \;
find and rm are basic linux utilities.
Hi

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

Posted: Thu Mar 02, 2017 6:39 pm
by skurudo
magzen, please stay in one topic, there is no need to duplicate question.