下面是一个简单的python脚本,我想在linux上使用nohup运行它。我使用以下(在linux上)运行它:
nohup python test.py &该命令似乎什么也不做,没有任何附加到nohup.out。如果我在没有“&”的情况下运行它,输出将正确地显示在终端窗口上。我遗漏了什么?
import time
def test():
while(True):
print "Woke up!"
time.sleep(5)
if __name__ == "__main__":
test()发布于 2015-08-26 00:42:11
尝试使用命令nohup python -u test.py &运行它。这将使输出没有缓冲。
您可以通过使用-u选项作为第一行添加一个bang路径来使脚本可执行。您还需要使用命令chmod +x test.py设置可执行位。
#!/usr/bin/python -u
import time
....然后您可以以nohup test.py &的形式运行它。
发布于 2015-08-25 20:58:59
我猜是基于块的I/O缓冲。如果在标准输出上设置setvbuf(3)等效的基于行的输出或未缓冲的输出,会发生什么?
https://unix.stackexchange.com/questions/225460
复制相似问题