Skip to content

Instantly share code, notes, and snippets.

@wamonite
Last active August 8, 2023 13:50
Show Gist options
  • Save wamonite/333d176c1af1eed79302d6ef3156f0b7 to your computer and use it in GitHub Desktop.
Save wamonite/333d176c1af1eed79302d6ef3156f0b7 to your computer and use it in GitHub Desktop.
find one-liner to list processes by their oom_score
#!/usr/bin/env bash
find /proc/ -maxdepth 2 -name oom_score -exec bash -c 'pid=$(cut -d '/' -f 3 <<< $1) ; echo -n "$pid " ; cat /proc/$pid/oom_score | tr "\n" " " ; head -n 1 /proc/$pid/cmdline | tr "\000" " " ; echo' func {} \; 2> /dev/null | sort -k2nr -k1nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment