解决nohup不能及时打印python print日志

1、程序后台运行

nohup python test.py > tt.log>&1 &

2、不能及时输出日志

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

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

nohup python -u test.py>tt.log>&1 &

猜你喜欢

转载自blog.csdn.net/qq_38890412/article/details/105660596