Skip to content

Instantly share code, notes, and snippets.

@JJ
Last active July 1, 2017 07:42
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/d42b5d13820ae4f7ef72b2195f43da41 to your computer and use it in GitHub Desktop.
Save JJ/d42b5d13820ae4f7ef72b2195f43da41 to your computer and use it in GitHub Desktop.
Get the process consuming the most CPU with a trimmed down version of ps, i.e., in busybox
# get the list of PIDs and cpu usage via the batch version of top if ps is not fully functional, take out the headers, sort numerically using the 9th column, which is the CPU usage as key, take the last one, and extract the second column
top -n 1 -b | tail -n +8 | sort -k9 -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