在 CentOS 里用 nohup 启动程序时,通常会把输出重定向到日志文件(常见是 nohup.out),查看“进程 + 日志”一般分几步:
ps -ef | grep 你的程序名
或
ps aux | grep 你的程序名
例如:
ps -ef | grep java
jobs -l
注意:
jobs只在你启动 nohup 的那个终端会话中有效,断开后看不到。
pgrep -fl 程序名
如果启动时是:
nohup command &
日志默认写在当前目录的:
nohup.out
查看:
tail -f nohup.out
比如你启动时是:
nohup command > app.log 2>&1 &
查看日志:
tail -f app.log
常用命令:
tail -100 app.log # 看最后100行
tail -f app.log # 实时刷新
less app.log # 分页查看
grep "ERROR" app.log # 搜关键字
ps -ef | grep app名
lsof -p PID
top -p PID
启动:
nohup python app.py > run.log 2>&1 &
查看进程:
ps -ef | grep app.py
查看日志:
tail -f run.log
如果你愿意,可以把你具体的启动命令或**程序类型(Java / Python / Shell 等)**发出来,我可以直接给你最合适的查看方式。