Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Technical

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 10th September 2007, 04:48
cruz cruz is offline
Senior Member
 
Join Date: Apr 2007
Posts: 365
Thanks: 51
Thanked 2 Times in 2 Posts
Default setting up crontabs

I have to setup 4 crontabs to run 4 scripts every hour. Is this the corect way to set up one of the scripts?
HTML Code:
 crontab 0 * * * * /var/www/web4/web/cronjobs/delete_cache_files.php
Reply With Quote
Sponsored Links
  #2  
Old 10th September 2007, 17:41
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,126
Thanks: 4
Thanked 43 Times in 40 Posts
Default

if you want to run php files by cron install the phpX-cli package and then I think the correct syntax is:
Code:
0 * * * * php -f /var/www/web4/web/cronjobs/delete_cache_files.php
and if you don't want any feedback:
Code:
0 * * * * php -f /var/www/web4/web/cronjobs/delete_cache_files.php >/dev/null 2>&1
and actually I would add crons like this:

(1) create a text file "cron.txt"

(2) edit it to add the crontabs:
Code:
0 * * * * php -f /var/www/web4/web/cronjobs/delete_cache_files.php >/dev/null 2>&1
15 * * * * php -f /var/www/web4/web/cronjobs/script2.php >/dev/null 2>&1
30 * * * * php -f /var/www/web4/web/cronjobs/script3.php >/dev/null 2>&1
45 * * * * php -f /var/www/web4/web/cronjobs/script4.php >/dev/null 2>&1
Or if it's the same script running every 15 min:

Code:
0,15,30,45 * * * * php -f /var/www/web4/web/cronjobs/delete_cache_files.php >/dev/null 2>&1
(3) Save and exit the file

(4) Run this command:
Code:
crontab /path/to/cron.txt
(5) Check if it was added:
Code:
crontab -l
I think managing cron with such a text file is simpler.
Reply With Quote
  #3  
Old 11th September 2007, 01:51
cruz cruz is offline
Senior Member
 
Join Date: Apr 2007
Posts: 365
Thanks: 51
Thanked 2 Times in 2 Posts
Default thanks for the crontab help

That was nice and easy. I createdd the cron.txt and added the strings in there and then ran crontab /path/to/cron.txt. will they now run every hour around the clock?
HTML Code:
0 * * * * php -f /var/www/web4/web/cronjobs/delete_cache_files.php >/dev/null 2>&1
0 * * * * php -f /var/www/web4/web/cronjobs/speeddater_email.php >/dev/nul 2>&1
0 * * * * php -f /var/www/web4/web/cronjobs/mship_expiry_reminder_mail.php >/dev/null 2>&1
0 * * * * php -f /var/www/web4/web/cronjobs/mymatches_email.php >/dev/null 2>&1
Reply With Quote
  #4  
Old 11th September 2007, 17:59
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

Quote:
Originally Posted by cruz
will they now run every hour around the clock?
Yes, every full hour.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 12th September 2007, 06:58
cruz cruz is offline
Senior Member
 
Join Date: Apr 2007
Posts: 365
Thanks: 51
Thanked 2 Times in 2 Posts
Default great

thanks for the help.
Reply With Quote
  #6  
Old 12th September 2007, 11:06
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,126
Thanks: 4
Thanked 43 Times in 40 Posts
Default

does it work?
Reply With Quote
  #7  
Old 12th September 2007, 19:28
cruz cruz is offline
Senior Member
 
Join Date: Apr 2007
Posts: 365
Thanks: 51
Thanked 2 Times in 2 Posts
Default great

Yes it worked great. I created the cron file and it is working. I can see them when I run the command crontab -l. dose that mean they are running if I can see them? can I add cronjobs to this file and they will be ran as well?

Last edited by cruz; 12th September 2007 at 19:33.
Reply With Quote
  #8  
Old 12th September 2007, 19:57
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,126
Thanks: 4
Thanked 43 Times in 40 Posts
Default

well, you could have sent yourself an email with the output of the cronjobs...

if you want to add more crons, just edit the cron file and then do again:

Code:
crontab cron.txt
to actualize it.
Reply With Quote
  #9  
Old 12th September 2007, 21:04
bschultz bschultz is offline
Senior Member
 
Join Date: Jul 2006
Posts: 220
Thanks: 11
Thanked 10 Times in 10 Posts
Default

Can anyone tell me where the CROn error log is? I'm on Debian, and can't find it in /var/log.

Thanks.
Reply With Quote
  #10  
Old 12th September 2007, 23:07
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,126
Thanks: 4
Thanked 43 Times in 40 Posts
 
Default

should be in syslog...
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help. Apache don't start payne Server Operation 3 17th August 2007 15:57
Setting up Fail-Safe Server in ISPConfig ddcruver Installation/Configuration 4 16th August 2007 09:59
I cannot configured setting bonox General 1 25th June 2007 20:07
ISP general manegement setting dont save new setting adrenalinic Installation/Configuration 13 25th May 2006 14:55
Problem setting external mailserver erk Installation/Configuration 4 18th May 2006 10:56


All times are GMT +2. The time now is 06:30.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.