public
Created

Display memory usage top

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5 6 7 8 9
#!/bin/bash
# Display the top five applications memory users
# http://www.cyberciti.biz/faq/linux-check-memory-usage/#comment-51021
 
free -hto
echo ''
 
while read command percent rss; do if [[ "${command}" != "COMMAND" ]]; then rss="$(bc <<< "scale=2;${rss}/1024")"; fi; printf "%-26s%-8s%s\n" "${command}" "${percent}" "${rss}"; done < <(ps -
A --sort -rss -o comm,pmem,rss | head -n 20)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.