Skip to content

Instantly share code, notes, and snippets.

@insideClaw
Created August 28, 2014 11:46
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 insideClaw/5bc0c39f43d863d70ae2 to your computer and use it in GitHub Desktop.
Save insideClaw/5bc0c39f43d863d70ae2 to your computer and use it in GitHub Desktop.
Snippet to get CPU usage per process. Takes PID as an argument.
#!/bin/bash
if [ $# != 1 ]; then
echo "Usage: Provide the PID to check for CPU usage as an argument."
exit 1
else
PID=$1
fi
sleep 1 && pkill prstat &
prstat -p $PID | grep .*\..% | awk '{ print $9 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment