美文网首页
nohup不能及时打印python print日志

nohup不能及时打印python print日志

作者: 京漂的小程序媛儿 | 来源:发表于2019-05-14 19:17 被阅读0次

1、程序后台运行

nohup python test.py > nohup.out 2>&1 &

2、不能及时输出日志

nohup.out中显示不出来python程序中print的东西,这是因为python的输出有缓冲,导致nohup.out并不能够马上看到输出。

python 有个-u参数,使得python不启用缓冲。

nohup python -u test.py > nohup.out 2>&1 &

相关文章

网友评论

      本文标题:nohup不能及时打印python print日志

      本文链接:https://www.haomeiwen.com/subject/hnieaqtx.html