我有一个简单的 python 脚本,它只运行一个无限的 while 循环并打印“正在运行”。当我在后台使用 nohup 启动它时,我在当前目录中看到一个 nohup.out 文件,但没有写入任何内容。我很困惑。我试过以下
nohup test.py
写入 nohup.out 但显然不在后台运行
nohup test.py &
在后台运行但不写入 nohup.out
nohup test.py 2>&1 &
也在后台运行,但不写入 nohup.out
我敢打赌我错过了一些简单的东西。有任何想法吗?
这是我的python脚本供参考:
import sys
from time import sleep
def main():
print "Starting...."
while True:
print "running..."
sleep(5.00)
if __name__ == "__main__":
main()