在 CentOS 里用 nohup 启动程序时,默认日志位置取决于你启动命令怎么写的。
如果你是这样启动的:
nohup your_command &
那日志默认会写到当前目录下的:
nohup.out
查看方式:
tail -f nohup.out
或:
cat nohup.out
less nohup.out
比如:
nohup your_command > app.log 2>&1 &
那日志就在你指定的文件里:
tail -f app.log
如果程序是通过 systemctl 启动的,那就不是 nohup 日志,而是:
journalctl -u 服务名
例如:
journalctl -u nginx
journalctl -u myapp.service -f
ps -ef | grep 程序名
假设 PID 是 1234:
ls -l /proc/1234/cwd
nohup.out 通常就在那个目录。
find / -name nohup.out 2>/dev/null
nohup your_command > /var/log/myapp.log 2>&1 &
这样日志位置清晰、好维护。
如果你愿意,可以把你启动命令贴出来,我可以直接告诉你日志在哪。