用nohup执行python程序时,print无法输出

来源:互联网 发布:zebra标签打印软件 编辑:程序博客网 时间:2024/06/04 19:26

nohup python test.py > nohup.out 2>&1 &
发现nohup.out中显示不出来python程序中print的东西。
这是因为python的输出有缓冲,导致nohup.out并不能够马上看到输出。
python 有个-u参数,使得python不启用缓冲。
nohup python -u test.py > nohup.out 2>&1 &

原创粉丝点击