0

I do "crontab -e" and add the following line:

0   9    *   *   *      /usr/bin/python /home/g1/g1/utils/statsEmail.py > /home/g1/log/statsemail.log

But it doesn't work! Why? The script itself works. Also, the log is empty.

My other command in crontab is this, and it works:

0   9    *   *   *      /usr/bin/python /home/g1/g1/sphinx/updateall.py > /home/g1/log/updateall.log
4
  • 6
    My guess is that there is a bug in the script that makes some assumptions about the environment that is not true when it is being ran from cron.
    – Zoredache
    Jun 14, 2010 at 21:53
  • But when I run this, it works: /usr/bin/python /home/g1/g1/utils/statsEmail.py
    – Alex
    Jun 14, 2010 at 21:55
  • Did you check the email being sent to root? Jun 14, 2010 at 22:05
  • Make sure permissions for the script and log are appropriate for whichever user's cron you're putting this in.
    – Cory J
    Jun 14, 2010 at 23:47

2 Answers 2

5

you can add MAILTO=youremail to the crontab to get detials of the failure and fix this.

EDIT: probably your cron cannot run your script because it is not permitted to do this

2

You are writing STDOUT to a logfile, but you should also pipe STDERR to the same logfile. Right now, you probably won't see any error messages generated by this script.

Your script may be failing due to something simple, like the user executing the cronjob doesn't have permission to execute the script. Also, remember that cron executes commands in a very simple environment, and may be very different then your regular interactive shell environment.

Change your script to this:

0   9    *   *   *      /usr/bin/python /home/g1/g1/sphinx/updateall.py > /home/g1/log/updateall.log 2>&1

What does updateall.log show you now?

Also, cron usually logs some information to a logfile. What does /var/log/cron.log say about your cronjob?

You must log in to answer this question.

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