Debian nohup 日志排查问题实操指南
一 定位与查看日志
nohup your_command > output.log 2>&1 &。cat nohup.outless nohup.out / more nohup.outtail -f nohup.outnohup your_command | tee output.log &。二 快速定位错误与关键事件
grep -i "error" nohup.outgrep -n "Exception\|Traceback\|FATAL\|panic" nohup.outawk '/2025-11-24/ && /error/' nohup.outgrep -n -A20 -B20 "error" nohup.outyour_command > stdout.log 2> stderr.log &三 常见症状与对应排查动作
ps aux | grep your_command 找到 PID,再 kill PID 清理;必要时查看系统日志(如 journalctl -u your_service 或 /var/log/syslog)确认退出原因。>> 追加,或使用 tee 同时输出到终端与文件。四 高效排查命令清单
tail -f nohup.outgrep -n "error" nohup.outgrep -n -A20 -B20 "error" nohup.outawk '/2025-11-24 10:00/,/2025-11-24 12:00/ { if(/error/i) print }' nohup.outyour_command > stdout.log 2> stderr.log &ps aux | grep your_commandkill PID(必要时 kill -9 PID,谨慎使用)