Skip to content

Instantly share code, notes, and snippets.

@mgbckr
Created December 17, 2018 17:15
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 mgbckr/0479dc667c60edc1851775bf8899127f to your computer and use it in GitHub Desktop.
Save mgbckr/0479dc667c60edc1851775bf8899127f to your computer and use it in GitHub Desktop.
Script to show CPU usage (percent) by user
#!/bin/bash
# start with `watch -n 1 bash utop.sh` for continuous monitoring
top -b -n 1 | awk '
NR <= 7 { print; next }
{ a[$2] += $9 }
END {
for (i in a) {
printf "%-15s\t%s\n", i, a[i];
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment