在 Debian(或其他 Linux)下,使用 nohup 启动程序时,默认会把输出重定向到当前目录的 nohup.out 文件(除非你手动指定了日志文件)。下面从「找日志」「检索内容」「实时查看」三个层面说明。
ls -l nohup.out
通常在你执行 nohup 命令的目录。
如果你是这样启动的:
nohup python app.py > app.log 2>&1 &
那日志就是 app.log
ps -ef | grep nohup
# 或
lsof -p <PID> | grep txt
grep "ERROR" nohup.out
忽略大小写:
grep -i "error" nohup.out
显示行号:
grep -n "timeout" nohup.out
grep -E "ERROR|WARN" nohup.out
grep -c "Exception" nohup.out
grep "2026-01-21 10:" nohup.out
tail -f nohup.out
tail -f nohup.out | grep "ERROR"
tail -n 100 nohup.out
less nohup.out
在 less 中:
/关键字 搜索G 跳到末尾q 退出split -l 100000 nohup.out nohup_part_
nohup python app.py >> app.log 2>&1 &
或配合 logrotate 管理日志。
如果你愿意,可以告诉我:
我可以给你更精准的检索命令。