Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to call a shell script every 5 minutes, witch executes php file under root.

# crontab -l
*/5 * * * * /home/regularuser/


-rw-rw-rw-  1 root   root        162 Jun  6 23:40 call.php
-rwxr-xr-x  1 root   root         66 Jun  7 01:20 contents:

php -q /home/regularuser/call.php
echo "request processed"

My problem is that my php file doesn't get executed via crontab. However, if I call - everything works perfectly.

I'm new to crontab and shell scripting, so any advice/resources are welcome.

share|improve this question
Try dumping your environment with the script, that may make the problem clear. – whitequark Jun 7 '10 at 15:04
up vote 1 down vote accepted

Remember that Cron will run with a very minimal environment. Certain important things like PATH may be different then what you expected.

Try logging the output of the command to syslog, like this:

*/5 * * * * /home/regularuser/ 2>&1 | logger -t

This will print any stdout and stderr to your system logs, usually to /var/log/messages . From here, use 'grep /var/log/messages' to see your error, which will likely be 1-2 lines.

I often prefer to log errors like this, instead of spamming email. But this is only useful for short messages.

Once you find the error message, update your question with the error. Or, you might be able to figure this out for yourself ;)

share|improve this answer

Are you sure php is on the $PATH known by crontab? What if you use the full path (/what/ever/bin/php ?)

Also, cron is supposed to send the output of your command to your mail box. What does it says?

share|improve this answer

You must log in to answer this question.

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