How to tell when a script is executed by cron ?

Simon Dobner sdobner at scu.edu.au
Tue Feb 4 19:41:48 EST 2003


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