Running a Python script from crontab

Philip Semanchuk philip at semanchuk.com
Wed Dec 3 13:49:29 EST 2008


On Dec 3, 2008, at 1:33 PM, Astley Le Jasper wrote:

> On 3 Dec, 16:41, Philip Semanchuk <phi... at semanchuk.com> wrote:
>> On Dec 3, 2008, at 10:29 AM, Astley Le Jasper wrote:
>>
>>> I've included a switch to include or exclude theloggingto console.
>>> Whenloggingonly to file, the script runs fine.
>>
>>> Of course, I still don't understand whyduallogging, and specifically
>>> to the console, causes a problem and if anyone has any comments  
>>> about
>>> thedualoutputloggingcode above then I'd still be happy to hear
>>> about it.
>>
>> Trying to write non-ASCII characters perchance?
>
> Errmmm ... that's kind of spoookey. I using UTF-8 encoding as I have a
> lot of European language characters. But would that cause a problem
> when running from crontab but not in the terminal?
>
> Go on then ... spill the beans.


Oh, I don't know exactly. It's just what I thought of when you said  
that the problem occurs when logging to the console but not to files.  
I don't have a deep Unix background so I can't give you the details on  
what "the console" means to a cron job.

In my experience, the environment in which a cron job runs is  
different from the environment in which some command line scripts run  
(remember my earlier suggestion about needing to explicitly set the  
PATH?) and so if the console for a cron job differed from the console  
that a Python program sees when run in a terminal, that would not  
surprise me.

Hope it's a useful suggestion
Philip




More information about the Python-list mailing list