Created
April 5, 2021 11:52
-
-
Save valtoni/e2829844e313a6191e2ba6dbd2bbb0c0 to your computer and use it in GitHub Desktop.
Showing memory utilization by users. (from https://www.networkworld.com/article/3516319/showing-memory-usage-in-linux-by-process-and-user.html)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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