在 CentOS 上用 nohup 启动程序时,日志一般会重定向到文件,比如:
nohup your_command > app.log 2>&1 &
要实时查看日志,常用以下几种方式:
tail -f app.log
Ctrl + C 退出tail -F app.log
-f 更健壮tail -fn 100 app.log
less +F app.log
Ctrl + C 停止,可搜索(/关键字)F 继续实时跟踪tail -f app.log error.log
tail -f nohup.out
(默认 nohup 不指定重定向时会写 nohup.out)
生产环境推荐:
nohup your_command >> app.log 2>&1 &
tail -F app.log
如果你愿意,可以告诉我你具体的启动命令,我可以帮你写最合适的写法。