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

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
share|improve this question
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 '10 at 21:53
    
But when I run this, it works: /usr/bin/python /home/g1/g1/utils/statsEmail.py –  Alex Jun 14 '10 at 21:55
    
Did you check the email being sent to root? –  Ignacio Vazquez-Abrams Jun 14 '10 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 '10 at 23:47

2 Answers 2

up vote 6 down vote accepted

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

share|improve this answer

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?

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.