Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion
  • Search

Cron Job Delete cache in a directory

General questions about VestaCP
Locked
  • Print view
Advanced search
7 posts • Page 1 of 1
magzen
Posts: 47
Joined: Sat Sep 05, 2015 6:16 pm

Cron Job Delete cache in a directory

Post by magzen » Thu Apr 07, 2016 3:24 pm

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
Top

skamasle
Collaborator
Posts: 592
Joined: Mon Feb 29, 2016 6:36 pm

Re: Cron Job Delete cache in a directory

Post by skamasle » Thu Apr 07, 2016 6:52 pm

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.
Top

magzen
Posts: 47
Joined: Sat Sep 05, 2015 6:16 pm

Re: Cron Job Delete cache in a directory

Post by magzen » Fri Apr 08, 2016 9:04 pm

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.
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Cron Job Delete cache in a directory

Post by skurudo » Mon Apr 25, 2016 2:29 pm

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
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Cron Job Delete cache in a directory

Post by skurudo » Mon Apr 25, 2016 2:32 pm

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.
Top

magzen
Posts: 47
Joined: Sat Sep 05, 2015 6:16 pm

Re: Cron Job Delete cache in a directory

Post by magzen » Tue Dec 13, 2016 8:52 am

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
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Cron Job Delete cache in a directory

Post by skurudo » Thu Mar 02, 2017 6:39 pm

magzen, please stay in one topic, there is no need to duplicate question.
Top


Locked
  • Print view

7 posts • Page 1 of 1

Return to “General Discussion”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password