在 Debian(或其他 Linux 系统)上,使用 nohup 运行的程序通常会把输出重定向到日志文件(默认是 nohup.out,或你手动指定的文件)。分析这些日志,一般可以从以下几个层面入手:
nohup command &
日志默认生成在:
./nohup.out
常见写法:
nohup command > app.log 2>&1 &
或
nohup command >> app.log 2>&1 &
日志就在 app.log。
查看当前进程对应的日志:
ps aux | grep command
ls -l /proc/<PID>/fd
tail -f app.log
# 或
tail -F app.log # 文件被重建也能继续跟踪
tail -n 200 app.log
less app.log
# 或
head -n 100 app.log
grep -i error app.log
grep -i exception app.log
grep "2026-01-21 10:" app.log
grep -c error app.log
ps aux | grep command
top -p <PID>
journalctl -xe
dmesg | tail
dmesg | grep -i oom
awk '/2026-01-21/ {print}' app.log
grep "cost" app.log | awk '{print $NF}'
# 按大小分割
split -b 100M app.log app_part_
# 压缩旧日志
gzip app.log.old
程序没启动
nohup.out 是否有报错ldd)程序运行中退出
error / tracebackdmesg日志不更新
-u)nohup python -u app.py >> app.log 2>&1 &
或使用 systemd(更规范):
[Service]
ExecStart=/path/app
StandardOutput=append:/var/log/app.log
如果你有具体的日志内容或程序类型(如 Python / Java / Node),我可以帮你做更针对性的分析。