Skip to content

Instantly share code, notes, and snippets.

@jdvala
Created April 22, 2021 11:18
Show Gist options
  • Save jdvala/8a91eea5b92c8d37c57e880576a519ed to your computer and use it in GitHub Desktop.
Save jdvala/8a91eea5b92c8d37c57e880576a519ed to your computer and use it in GitHub Desktop.
who is using resources
#!/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