Redirecting Output from a Long Running Python app

Skip Montanaro skip at pobox.com
Thu Oct 31 18:01:01 CET 2002


    Neilen> I wrote some numeric code in python (using numpy, etc.), that
    Neilen> often needs to run for a while.  Therefore I wanted to use
    Neilen> nohup, to ensure it does not get accidentally killed if I close
    Neilen> an xterm or something similar.  The only problem is, no output
    Neilen> seems to be redirected to nohup.out, nor is anything printed to
    Neilen> the terminal.  My program is quite verbose, and I would have
    Neilen> liked to tail -f nohup.out, to see how its doing.

If I want to disconnect from the starting terminal and make sure my
program's output gets saved, I run it like:

    (python myscript.py >myscript.out 2>&1 </dev/null &)

(This is with the Bourne shell and friends - ksh, bash, etc.  Dunno how to
do this with csh and its derivatives.)  You will have to redirect stdin from
something other than /dev/null if you have inputs that normally come that
route.

-- 
Skip Montanaro - skip at pobox.com
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list