2

I have set up a cron job each 12 hours updating a mysql table. The problem is that the cron job keeps restarting randomly every 15 minutes. It doesnt stop the previous one, but instead runs on top of it. Today when I checked, there were 13 jobs doing the same thing.

What is going on? Im on a Linux Server and have setup the Cron Job in cPanel. Any help would be greatly appreciated.

2 Answers2

3
  1. Are you sure that the cronjob itself is executing every 15 minutes? Check the cron logfile to see if your cronjob is actually running every 15 minutes. The cron logfile is often at /var/log/cron or it may be logged to /var/log/messages. However, you may need to enable the cron logfile in /etc/syslog.conf (or /etc/rsyslog.conf) first.

  2. Get output from the script. By default on most systems, any output from this cronjob is emailed to the owner of the cronjob. I prefer to write the cron output and error to a logfile. Change your cronjob to look like this:

    0 0,12 * * * /usr/bin/wget lazysundays.com >> /var/log/wget.cron.log 2>&1

Look at the output of the logfile, and you should find the error.

Stefan Lasiewski
  • 22,949
  • 38
  • 129
  • 184
2

can it be that wget times out and re-tries and re-tries and re-tries again?

give wget parameter --tries 1 so it tries only once, add to it --timeout=600 or so - so it does not give up too quickly, and on the top of your script on the server - add something that makes sure php/pearl/whatever else does not timeout too quickly on the server side.

pQd
  • 29,561
  • 5
  • 64
  • 106
  • pQd, if you do not mind, could you be more specific with what I should do. Im not too experienced in this. –  Jul 14 '10 at 16:26
  • @Petruuz - change your cron syntax into : `0 0,12 * * * /usr/bin/wget --tries 1 --timeout=600 lazysundays.com` – pQd Jul 14 '10 at 21:38