
nohup python flush.py &
这样运行,能够生成nohup.out文件,但是内容始终是空的。具体原因:python的输出是有缓冲的,即使在py脚本中每次遍历都有打印输出,但是因为缓冲的作用,我们不能在nohup.out日志中立即看到打印的输出。
nohup python -u flush.py > flush.log 2>&1 &
-u 参数,使得python不启用缓冲。
如果python带参数也是一样的
nohup python -u train4.py train_base configs/magicpoint_shapes_pair.yaml magicpoint_synth --eval > nohup.out 2>&1 &
解析:
前台实时查看nohub.out文件内容:
tail -f nohup.out
根据关键字查看
tail -f nohup.out |grep "关键字"
输出文件最后100行
tail -n 100 nohup.out
输出文件最后100行,含关键字
tail -n 100 nohup.out |grep "关键字"