Python without a tty

Bradley Cloete bcloete at gmail.com
Thu Sep 29 16:45:53 CEST 2011


> It doesn't appear so to me.
>
> [steve at sylar ~]$ tty
> /dev/pts/16
> [steve at sylar ~]$ setsid tty
> /dev/pts/16
>
> [steve at sylar ~]$ python -c "import sys,os; print
> os.isatty(sys.stdout.fileno())"
> True
> [steve at sylar ~]$ setsid python -c "import sys,os; print
> os.isatty(sys.stdout.fileno())"
> True
>
>
> If I run the same Python command (without the setsid) as a cron job, I
> get False emailed to me. That's the effect I'm looking for.
>
>
Maybe nohup is what you looking for?

>From the info pages...

"`nohup' runs the given COMMAND with hangup signals ignored, so that the
command can continue running in the background after you log out.
Synopsis:

     nohup COMMAND [ARG]...

   If standard output is a terminal, it is redirected so that it is
appended to the file `nohup.out'; if that cannot be written to, it is
appended to the file `$HOME/nohup.out'.  If that cannot be written to,
the command is not run.  If standard output is not a terminal, then the
standard output of COMMAND will be the same as that of `nohup'.

"

Regards
Bradley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110929/4e6b60e1/attachment.html>


More information about the Python-list mailing list