温馨提示×

ubuntu nohup日志在哪查找

小樊
44
2026-10-21 07:24:04
栏目: 智能运维

在 Ubuntu 中,使用 nohup 启动程序时,默认会把输出重定向到当前目录下的 nohup.out 文件,除非你手动指定了日志文件。

1. 默认日志位置

nohup command &

日志一般在:

当前工作目录/nohup.out

例如你在 /home/user/ 下执行命令:

cd /home/user
nohup python app.py &

日志文件就是:

/home/user/nohup.out

查看日志:

cat nohup.out
tail -f nohup.out

2. 自定义日志位置(常见做法)

很多人会自己重定向日志:

nohup python app.py > app.log 2>&1 &

日志就在:

当前目录/app.log

或者指定绝对路径:

nohup python app.py > /var/log/app.log 2>&1 &

3. 如果找不到 nohup.out

可以用以下方式查找:

find / -name nohup.out 2>/dev/null

或根据进程找:

ps aux | grep 程序名
ls -l /proc/进程ID/fd

4. 查看实时日志

tail -f nohup.out

总结

  • 默认:./nohup.out
  • 自定义:看你重定向到了哪里
  • 查找:find / -name nohup.out

如果你愿意,可以告诉我你运行的命令,我可以帮你精确定位日志文件。

0 踩