生成nohup.out文件,查看nohup.out文件



一、生成nohun.out文件

nohup python train.py &
或者
nohup python -u train.py > nohup.out 2>&1 &

注:nohup是使进程不挂起运行,断网程序不会结束,需要自己杀手进程,以nohup开头(右侧一个空格),以&结尾(左侧一个空格),有时因为缓冲区原因使用nohup python train.py &不能将输出实时写进nohup.out文件,可以使用下面一个nohup python -u train.py > nohup.out 2>&1 &

二、查看nohun.out文件

1.前台实时查看nohub.out文件内容:
tail -f nohup.out

2.根据关键字查看
tail -f nohup.out |grep “关键字”

3.输出文件最后500行
tail -n 500 nohup.out

4.输出文件最后2000行,含关键字
tail -n 2000 nohup.out |grep “关键字”


Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐