在 Ubuntu 中,使用 nohup 启动程序时,默认会把输出重定向到当前目录下的 nohup.out 文件,除非你手动指定了日志文件。
nohup command &
日志一般在:
当前工作目录/nohup.out
例如你在 /home/user/ 下执行命令:
cd /home/user
nohup python app.py &
日志文件就是:
/home/user/nohup.out
查看日志:
cat nohup.out
tail -f nohup.out
很多人会自己重定向日志:
nohup python app.py > app.log 2>&1 &
日志就在:
当前目录/app.log
或者指定绝对路径:
nohup python app.py > /var/log/app.log 2>&1 &
可以用以下方式查找:
find / -name nohup.out 2>/dev/null
或根据进程找:
ps aux | grep 程序名
ls -l /proc/进程ID/fd
tail -f nohup.out
./nohup.outfind / -name nohup.out如果你愿意,可以告诉我你运行的命令,我可以帮你精确定位日志文件。