211

当 Linux 内存不足 (OOM) 时,OOM 杀手会根据一些启发式方法选择一个要杀死的进程(这是一个有趣的阅读: http: //lwn.net/Articles/317814/)。

如何以编程方式确定最近被 OOM 杀手杀死的进程?

4

4 回答 4

201

试试这个:

grep -i 'killed process' /var/log/messages
于 2009-03-09T02:54:54.987 回答
196

试试这个,这样你就不必担心你的日志在哪里:

dmesg -T | egrep -i 'killed process'

-T, --ctime- 打印人类可读的时间戳。

于 2013-04-11T15:58:36.073 回答
57

现在 dstat 提供了在你正在运行的系统中找出哪个进程可能被 oom 机制杀死的功能

dstat --top-oom
 --out-of-memory---
  kill score
 java           77
 java           77
 java           77

并根据手册页

  --top-oom
          show process that will be killed by OOM the first
于 2014-09-02T11:32:09.667 回答
20

试试这个:

grep "Killed process" /var/log/syslog
于 2013-03-26T05:18:48.937 回答