Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- for score_file in `ls /proc/*/oom_score 2>/dev/null`;
- do
- score=$(cat $score_file 2>/dev/null);
- if [[ x$score != 'x' ]]; then
- if [[ $score > 100 ]]; then
- pid=$(echo $score_file 2>/dev/null | awk -F'/' '{print $3}')
- if [[ x$pid != 'x' ]]; then
- cmdline=$(cat /proc/$pid/cmdline 2>/dev/null | tr '\000' ' ')
- if [[ x$cmdline != 'x' ]]; then
- echo $pid, $score, $cmdline >> /tmp/cmdline
- fi
- fi
- fi
- fi
- done
- # 怎么用呢?
- # 排序目前 oom score 最大的 pid,也就是被 oom-killer 风险最大的进程:cat /tmp/cmdline | sort -rnk2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement