在 CentOS 上,nohup 默认会把输出写到 当前目录下的 nohup.out(或你重定向的文件)。要实时查看日志,常用下面几种方式:
tail -f nohup.out
-f:实时滚动显示Ctrl + C 退出如果文件不在当前目录:
tail -f /path/to/nohup.out
tail -n 100 -f nohup.out
先找进程:
ps -ef | grep 进程名
再看日志文件(假设你知道日志路径):
tail -f nohup.out
或:
lsof -p PID | grep log
例如启动方式是:
nohup java -jar app.jar > app.log 2>&1 &
那么日志在 app.log:
tail -f app.log
less(可来回翻)less +F app.log
F:实时追踪Ctrl + C 暂停Shift + F 继续q 退出multitail(同时看多个日志)yum install -y multitail
multitail nohup.out app.log
可能原因:
解决:
nohup java -jar app.jar > app.log 2>&1 &
# 启动
nohup ./app.sh > app.log 2>&1 &
# 实时看
tail -f app.log
如果你能贴出 nohup 启动命令 或 程序类型(Java / Python / Shell),我可以帮你给出最合适的方案。