在 CentOS 中,nohup 命令默认会把程序的输出重定向到当前目录下的 nohup.out 文件(如果未显式指定输出文件)。查看日志的方法如下:
cat nohup.out
tail -f nohup.out
或
tail -F nohup.out # 文件被重建也能继续跟踪
tail -n 100 nohup.out
less nohup.out
(按 q 退出)
如果你启动时是这样的:
nohup python app.py > app.log 2>&1 &
那么日志在 app.log:
tail -f app.log
如果忘了日志在哪:
ls -l nohup.out
或
find / -name nohup.out 2>/dev/null
ps -ef | grep 程序名
查看进程对应的文件描述符:
ls -l /proc/进程ID/fd
# 实时查看并过滤错误
tail -f nohup.out | grep ERROR
# 查看日志大小
du -h nohup.out
如果你愿意,可以告诉我你 具体的启动命令,我可以帮你精确判断日志在哪里。