Skip to content

Instantly share code, notes, and snippets.

@JJ
Last active July 1, 2017 07:30
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 JJ/00d60f2347252fd950654375951612c6 to your computer and use it in GitHub Desktop.
Save JJ/00d60f2347252fd950654375951612c6 to your computer and use it in GitHub Desktop.
Get the process PID consuming the most CPU
# get the list of PIDs and cpu use, sort numerically using the second column or key, take the last one, and extract the second column
ps —no-headers -eo pid,%cpu | sort -k2 -n | tail -1 | cut -d ' ' -f 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment