How to tell when a script is executed by cron ?

dsavitsk dsavitsk at e-coli.net
Tue Feb 4 22:40:16 EST 2003


I don't know about other flavors, but on FreeBSD print output will be sent
to you via email. So just add "print 'hello'" to your script.

-d


"Simon Dobner" <sdobner at scu.edu.au> wrote in message
news:pan.2003.02.05.00.41.45.753357 at scu.edu.au...
> Hi,
>
> I want to know how to tell if a script is being executed in the background
> by cron, as opposed to running in the foreground from the command prompt.
>
> I want to do this so I can direct the output from the script to a logfile
> if it is running via cron, and to the screen if its running from cron.
>
> I don't need to worry about cases like jobs startnig in the forground and
> being backgounded.
>
> I'm using Unix and Python V2.2.2
>
>
> TIA
>
> Simon






More information about the Python-list mailing list