[Tutor] Running a script in the background
dwightdhutto at gmail.com
Mon Sep 3 23:46:43 CEST 2012
On Sun, Sep 2, 2012 at 9:03 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, Sep 02, 2012 at 03:14:53PM -0700, Ray Jones wrote:
> > This is only tangentially related to the thread. Someone mentioned that
> > so long as a script didn't require user input or output to the user, it
> > could run silently in the background. But is there a way for a Python
> > (2.7.3) script to determine whether it was called by the user or called
> > by something like cron or kalarm? That way user inputs could be used
> > when called by a user, but defaults could be used if run by a bot.
> The usual way to detect this is by checking whether or not there is a
> terminal available.
> If the script is running directly in a console, isatty will return True;
> if it is running from cron, or via a pipe or similar, then it will
> return False.
But a script is always running in the background of the OS main console of
the upfront GUI app users usually see, correct?
Cron has to coninually run, or have another process that checks x number
per minute(hertz of the process) to see what is going on, so it all goes
back to a main script in OS runtime checking for processes to run, even for
other processes, for other processes, etc.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor