Ubuntu 下“进程崩溃”原因非常多,一般可以从下面几个层面来排查。我按最常见 → 较少见给你梳理一下,并给出对应的排查方法。
表现
dmesg 里出现 Out of memory: Kill process排查
dmesg | grep -i oom
或
journalctl -k | grep -i oom
解决
systemd / ulimit)表现
Segmentation fault (core dumped)原因
排查
ulimit -c unlimited
./your_program
然后:
gdb ./your_program core
表现
error while loading shared libraries排查
ldd your_program
看是否有 not found
表现
常见情况
排查
strace -f ./your_program
排查
apt history
journalctl -b
df -h
df -i
mount | grep "ro,"
如果是 systemd 服务崩溃:
systemctl status your_service
journalctl -u your_service -b
常见原因:
Restart=no排查
dmesg
journalctl -k
memtester
journalctl -xe
dmesg
strace -f -o log.txt your_program
你可以补充:
我可以按你的情况直接告诉你最可能是哪一个原因。