2

I've set up a cron job to wget a PHP script every hour. However, it seems to get stuck in a loop and constantly running. If I run the script in a browser or via the command line it works fine. I've tried using wget and command line PHP and I get the same problem.

Here's my job:

0, 9-18, * * 1-5 wget http://www2.lichfielddc.gov.uk/planning/cron.php
3
  • Do you have any logfile output from cron?
    – Sven
    Apr 21, 2011 at 10:33
  • you should check the script and debug it, if it gets stuck in a loop then there's nothing you can do without changing the php script
    – quamis
    Apr 21, 2011 at 10:56
  • I've tried it with a one line script which just outputs "hello" and I still get the same behaviour
    – Pezholio
    Apr 21, 2011 at 11:51

1 Answer 1

4

Remove the commata from your minute and hour columns. Specify timeouts and retries explicitely like with

0 9-18 * * 1-5 wget -a /tmp/cron.log --tries=1 --timeout=90 http://www.example.com

You may want to add a log during your tests, this is done with -a in the example.

[Edit after comment:]

To get to know that it's not smth. wget specific you could replace your cron command line with a timout command that has a higher duration than the 90secs timeout I added in my example:

timeout --kill-after=110 --signal=15 110 wget -a /tmp/cron.log --tries=1 --timeout=90 http://www.example.com

wget should stop after 90 secs, if not, timeout terminates it after 110 secs. (signal SIGTERM=15 should be sufficient, if not use SIGKILL=9).

3
  • OK, cool, I've got that now. Checking the log file it seems to be constantly running still. Looking at my log file I just get: Resolving www2.lichfielddc.gov.uk... 212.110.185.246 Connecting to www2.lichfielddc.gov.uk|212.110.185.246|:80... connected. HTTP request sent, awaiting response... --2011-04-21 12:47:00-- www2.lichfielddc.gov.uk/planning/cron.php Ad infinitum. I've tried it with a test script which just outputs "Hello" and it does the same thing, so it's definitely not my code.
    – Pezholio
    Apr 21, 2011 at 11:50
  • Yeah, still get the same problem. It's strange because I've got other jobs that run fine?
    – Pezholio
    Apr 21, 2011 at 13:33
  • 1
    Ok, then try curl instead of wget: curl -m 90 -o /tmp/curl.log www.example.com.
    – initall
    Apr 21, 2011 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .