Skip to content

Instantly share code, notes, and snippets.

@rvbhute
Created March 22, 2013 10:35
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 rvbhute/5220386 to your computer and use it in GitHub Desktop.
Save rvbhute/5220386 to your computer and use it in GitHub Desktop.
Useful snippet to calculate total memory used by a process
#!/bin/sh
# psmem.sh
# http://abdussamad.com/archives/488-Memory-usage-of-a-process-under-Linux.html
ps -C $1 -O rss | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =",count; print "Memory usage per process =",sum/1024/count, "MB"; print "Total memory usage =", sum/1024, "MB" ;};'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment