查找 Linux OOM 杀手杀死了哪个进程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/624857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:05:13  来源:igfitidea点击:

Finding which process was killed by Linux OOM killer

linuxlinux-kernel

提问by Yang

When Linux runs out of memory (OOM), the OOM killer chooses a process to kill based on some heuristics (it's an interesting read: http://lwn.net/Articles/317814/).

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

How can one programmaticallydetermine which processes have recently been killed by the OOM killer?

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

采纳答案by John Feminella

Try this out:

试试这个:

grep -i 'killed process' /var/log/messages

回答by Praveen

Try this out:

试试这个:

grep "Killed process" /var/log/syslog

回答by Jose Fernandez

Try this so you don't need to worry about where your logs are

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

dmesg | egrep -i 'killed process'

回答by Prashant Lakhera

Now dstat provides the feature to find out in your running system which process is candidate for getting killed by oom mechanism

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

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

and as per man page

并根据手册页

  --top-oom
          show process that will be killed by OOM the first