Skip to content

Instantly share code, notes, and snippets.

@valtoni
Created April 5, 2021 11:52
Show Gist options
  • Save valtoni/e2829844e313a6191e2ba6dbd2bbb0c0 to your computer and use it in GitHub Desktop.
Save valtoni/e2829844e313a6191e2ba6dbd2bbb0c0 to your computer and use it in GitHub Desktop.
#!/bin/bash
stats=””
echo "% user"
echo "============"
# collect the data
for user in `ps aux | grep -v COMMAND | awk '{print $1}' | sort -u`
do
stats="$stats\n`ps aux | egrep ^$user | awk 'BEGIN{total=0}; \
{total += $4};END{print total,$1}'`"
done
# sort data numerically (largest first)
echo -e $stats | grep -v ^$ | sort -rn | head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment