分析 nohup 日志报错,通常可以按照下面这套思路一步步来。
用 nohup 启动程序时,常见形式:
nohup python app.py > app.log 2>&1 &
或
nohup ./start.sh > nohup.out &
常见日志文件:
nohup.out(默认)app.log)logs/error.log)先确认你在看的是正确的日志文件。
# 实时查看
tail -f nohup.out
# 看最后 200 行
tail -n 200 nohup.out
# 搜索错误关键字
grep -i error nohup.out
grep -i exception nohup.out
grep -i traceback nohup.out
典型表现:
常见原因:
示例(Python):
ModuleNotFoundError: No module named 'requests'
✅ 解决:安装依赖
示例:
Permission denied
检查:
ls -l 程序文件
whoami
✅ 解决:
chmod +x示例:
Address already in use
查看端口:
lsof -i:8080
netstat -tunlp | grep 8080
✅ 解决:
示例:
Cannot allocate memory
Killed
检查:
free -h
dmesg | grep -i kill
✅ 解决:
表现:
检查:
ps -ef | grep 程序名
strace -p 进程ID
✅ 从下往上看:
✅ 找关键字:
ErrorExceptionFATALTracebackcore dumped✅ 对比正常环境:
如果你愿意,可以把 nohup 日志中的具体报错内容贴出来,我可以直接帮你定位原因并给出解决方案。