nohup 默认会把输出写到 nohup.out,想实时查看日志,常用下面几种方式:
tail -f nohup.out
-f:持续输出(follow)Ctrl + Ctail -n 100 -f nohup.out
先看最后 100 行,然后实时刷新
less nohup.out
进入后:
Shift + F:实时跟踪(类似 tail -f)Ctrl + C 停止跟踪q 退出如果你是这么启动的:
nohup java -jar app.jar > app.log 2>&1 &
那就看指定文件:
tail -f app.log
tail -f nohup.out app.log
tail -f nohup.out | grep ERROR
lsof nohup.out
或
ps -ef | grep 进程名
java -jar -Dspring.output.ansi.enabled=ALWAYS app.jar
或
stdbuf -oL nohup java -jar app.jar > app.log 2>&1 &
: > nohup.out
或
truncate -s 0 nohup.out
如果你愿意,可以把 启动命令 或 程序语言(Java / Python / Shell) 发我,我可以给你更精准的实时日志方案。