Running a Python script from crontab

Philip Semanchuk philip at semanchuk.com
Fri Dec 5 05:27:34 CET 2008


On Dec 4, 2008, at 4:21 AM, Astley Le Jasper wrote:

> On Dec 4, 12:34 am, Lawrence D'Oliveiro <l... at geek-
> central.gen.new_zealand> wrote:
>> In message <mailman.4867.1228330173.3487.python-l... at python.org>,  
>> Philip
>>
>> Semanchuk wrote:
>>> In my experience, the environment in which a cron job runs is
>>> different from the environment in which some command line scripts  
>>> run...
>>
>> Which is true, but again, cron should report the environment in the  
>> mail
>> message. For example, here are some headers from a recent run of the
>> maildir backup task I have scheduled twice a day:
>>
>>     Subject: Cron <ldo at theon> $HOME/bin/backupdir $HOME/.maildir
>>     X-Cron-Env: <SHELL=/bin/sh>
>>     X-Cron-Env: <HOME=/home/ldo>
>>     X-Cron-Env: <PATH=/usr/bin:/bin>
>>     X-Cron-Env: <LOGNAME=ldo>
>>     X-Cron-Env: <USER=ldo>
>
> Where do you get the emails from?

In my experience, this depends on the machine config. The machine  
*should* be set up to email the user when a cron job fails. You'll log  
in via terminal and get the message "You have new mail" which means  
something went wrong with your cron job. As Lawrence said, run mail in  
the terminal window and you'll have a message from cron. You might not  
be getting these mails for some reason.





More information about the Python-list mailing list