Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a hourly cronjob script that curls a php script. The php script isn't being executed. In crontab -e I have:

1 * * * * /var/www/path/to/script.sh

Doing grep cron /var/log/syslog outputs:

Mar 23 21:45:01 Emile CRON[5339]: (root) CMD (/var/www/path/to/anotherscript.sh)
Mar 23 22:01:01 Emile CRON[5386]: (root) CMD (/var/www/path/to/anotherscript.sh)
Mar 23 22:01:01 Emile CRON[5387]: (root) CMD (/var/www/path/to/script.sh)
Mar 23 22:14:01 Emile CRON[5425]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 23 22:15:01 Emile CRON[5429]: (root) CMD (/var/www/path/to/anotherscript.sh)

I've verified that the url that is being curl in script.sh is correct and that the path in crontab -e is correct. I also verified that the php script works when manually executed. What else is there? Any ideas? Another way to diagnose? What's that cd / && run-parts in my syslog?

Thanks in advance for the help!

share|improve this question
1  
Have you checked your user's mail spool for error messages? run-parts is used to run all the scripts placed in the cron.hourly and cron.daily (and weekly and monthly) directories. –  DerfK Mar 23 '11 at 22:51
    
When you say manually executed, do you mean "php /path/to/phpfile.php" or "curl url/to/phpfile.php";? The first confirms that the .php file is valid and executable, the second will confirm if it can be gotten to via http, and if the web server will allow it to run. –  malcolmpdx Mar 23 '11 at 23:46

1 Answer 1

up vote 3 down vote accepted

What usually can happen is a $PATH problem. It's curl being used with it's full path on script.sh or just curl?

You can also change the first line of the script (if you are using bash) from #!/bin/bash to #/bin/bash -x (that will generate debug output from bash).

Anyway, as @derfK said on his comment, check the user email for errors (the script debug will also be sent to the user email). You can change the email which cron uses to send messages putting MAILTO=<email> before the rule lines.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.