Leif160519的blog Leif160519的blog

——————

目录
linux后台运行脚本并输出到日志文件
/    

linux后台运行脚本并输出到日志文件

方法:

使用命令

nohup python -u test.py > test.log 2>&1 &
  • 最后&表示后台运行
  • 2输出错误信息到提示符窗口
  • 1表示输出信息到提示符窗口,1前面的&注意添加,否则还会创建一个名为1的文件

最后会把日志文件输出到test.log文件

查看

实时查看日志文件:

tail -f test.log

查看全部输出:

cat test.log

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题linux后台运行脚本并输出到日志文件
作  者Leif160519
出  处https://github.icu/articles/2019/09/06/1567749170253.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!