ybaidukuai 发表于 2017-4-26 10:29:03

nohup python xx.py & 无输出信息

python默认的print输出stdout是开启了buffered IO,所以print先输出到缓冲区,等执行完毕后才能一次性flush出去。
解决方法有以下几种:
1.使用-u参数,使得python不启用缓冲  ( 使用过,有效)

nohup python -u test.py >out.log &
2.在print之后加上

sys.stdout.flush()

3. 重新设置sys.stdout

sys.stdout = os.fdopen(sys.stdout.fileno(),'w',0)
页: [1]
查看完整版本: nohup python xx.py & 无输出信息