Strange python script behaviour

Loïc Domaigné loic.domaigne at googlemail.com
Tue Aug 4 05:11:21 EDT 2009


> > > I have a problem with one of my python scripts. When I run this script
> > > from command line it works correctly, but if I set up cron to run this
> > > script on specified hour it works for a while and then "[Errno 32]
> > > Broken pipe" error occures (always).
>
> > > The strangest thing is that if I change command in CRON
>
> > > from
> > > python /home/xxx/script.py
> > > to
> > > python /home/xxx/script.py  > /tmp/script.log 2>&1
>
> > > the script always works correctly!!!
>
> > > The question is WHY? Any ideas?
>
> > This is a cron issue, and has little with python to do.
>
> > By default, cron will email the output produced by your script, unless
> > you redirect. It does so by pipe to a "mail" program. Your error seems
> > to indicate a problem with the latter (perhaps you don't have any
> > "mail" program installed).
>
> Hmm... interesting, but logical explanation. Cron has its weird
> issues. I guess I have to redirect outputs of all my scripts to /dev/
> null in order to prevent them from this kind of error.

You could also set the MAILTO variable to "".


HTH,
Loïc
--
My Blog: http://www.domaigne.com/blog

"Hardware: The parts of a computer system that can be kicked." -- Jeff
Pesis.



More information about the Python-list mailing list