在 CentOS 中,使用 nohup 启动程序时,默认会把输出重定向到当前目录下的 nohup.out 文件(如果你没有手动指定日志文件)。下面给你几种常见的“导出 / 查看 nohup 日志”的方法。
cat nohup.out
tail -f nohup.out
退出:Ctrl + C
tail -n 100 nohup.out
less nohup.out
空格qnohup your_command > app.log 2>&1 &
说明:
> app.log:标准输出2>&1:错误输出也写入&:后台运行查看日志:
tail -f app.log
cat nohup.out > /tmp/nohup_backup.log
scp user@centos_ip:/path/nohup.out ./local/
> nohup.out
grep "2026-01-21" nohup.out
可能原因:
查找:
find / -name nohup.out 2>/dev/null
或查看进程启动参数:
ps -ef | grep your_command
如果你愿意,可以告诉我:
我可以给你更精确的命令。