Running a Python script from crontab

Astley Le Jasper Astley.lejasper at gmail.com
Wed Dec 3 15:06:28 EST 2008


On 3 Dec, 19:49, Philip Semanchuk <phi... at semanchuk.com> wrote:
> 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

I tried using the path variables but it didn't help. There again, I
didn't really understand what was being passed in the path variables
and, rather than just copying and pasting, I wanted to look up further
info to get to grips with it. I've got something that works, so now
the pressure is off I can spend some time looking it up.

[sigh ... my experiences with linux haven't been that good so far. It
is, if nothing else, interesting]

Thanks

ALJ



More information about the Python-list mailing list