Skip to content

Instantly share code, notes, and snippets.

@niedbalski
Created August 18, 2020 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niedbalski/54097863077048bb3e8004daae1539dd to your computer and use it in GitHub Desktop.
Save niedbalski/54097863077048bb3e8004daae1539dd to your computer and use it in GitHub Desktop.
oom-score.sh
#!/bin/bash
# Displays running processes in descending order of OOM score
printf 'PID\tOOM Score\tOOM Adj\tCommand\n'
while read -r pid comm; do [ -f /proc/$pid/oom_score ] && [ $(cat /proc/$pid/oom_score) != 0 ] && printf '%d\t%d\t\t%d\t%s\n' "$pid" "$(cat /proc/$pid/oom_score)" "$(cat /proc/$pid/oom_score_adj)" "$comm"; done < <(ps -e -o pid= -o comm=) | sort -k 2nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment