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 &
就可以了
本文介绍如何解决使用nohup运行Python程序时,输出信息延迟显示的问题。通过添加-u参数,可以禁用Python的输出缓冲,使nohup.out文件能够实时显示程序输出。
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 &
就可以了

被折叠的 条评论
为什么被折叠?