Last Updated: February 25, 2016
·
850
· butenas_com

Know your applications memory usage on a server

Simple command which will help you to monitor memory usage by your (for your user you are logged in) applications on the server. Includes real RAM usage (RSS and Total RSS) and Virtual memory (VSZ):

ps -u `id -un` --sort -rss -o pid,rss,command:80,time,vsz | awk '{print $0}{sum+=$2} END {print "Total", sum}'

80 is the width of the column for the command, change it to to the one you want ;)

Also consider creating alias for this command (you don't want to type it every time or grepping in a history, right?):

# add this to bash (change umem to whatever you want it to be)
alias umem='ps -u `id -un` --sort -rss -o pid,rss,command:80,time,vsz | awk '\''{print $0}{sum+=$2} END {print "Total", sum}'\'''

If you want to use same command to monitor all the processes, replace -u id -un with -A, and for the other user use -u some_username.

1 Response
Add your response

I could recomend to use parameter -m instead of --sort rss. This makes this recipe works on Mac OS X

over 1 year ago ·