实时查看 nohup 启动进程的日志,其实就是实时查看 nohup 输出到的日志文件。常见做法如下:
一般你会这样启动:
nohup python app.py > app.log 2>&1 &
实时查看日志:
tail -f app.log
-f:持续跟踪文件新增内容Ctrl + C 退出默认会写到:
nohup.out
查看方式:
tail -f nohup.out
tail -n 100 -f app.log
只看最后 100 行并实时跟踪
tail -f app.log error.log
less +F app.logtail -f,但可搜索、暂停multitail(需安装)✅ 必须 > 重定向,否则可能没日志
✅ 2>&1 把错误也写进去
✅ 程序崩溃不会自动重跑(nohup 不等于守护进程)
如果你愿意,可以告诉我:
我可以给你更精确的命令。