【发布时间】:2011-08-26 01:21:46
【问题描述】:
我试过这样运行:
subprocess.Popen(['nohup', 'my_command'],
stdout=open('/dev/null', 'w'),
stderr=open('logfile.log', 'a'))
如果父脚本正常退出,则此方法有效,但如果我终止脚本 (Ctrl-C),我的所有子进程也会被终止。有没有办法避免这种情况?
我关心的平台是 OS X 和 Linux,使用 Python 2.6 和 Python 2.7。
【问题讨论】:
标签: python subprocess nohup