Skip to content

Instantly share code, notes, and snippets.

@JesseFinch
Last active July 11, 2017 15:14
Show Gist options
  • Save JesseFinch/363ebf3331969440266bbe59438f2718 to your computer and use it in GitHub Desktop.
Save JesseFinch/363ebf3331969440266bbe59438f2718 to your computer and use it in GitHub Desktop.
top 20 process by memory usage
#!/bin/bash
watch -n 1 'bash memory_usage.sh'
# show top 20 process ordered by memory usage
#!/bin/bash
ps axo rss,comm,pid \
| awk '{ proc_list[$2]++; proc_list[$2 "," 1] += $1; } \
END { for (proc in proc_list) { printf("%d\t%s\n", \
proc_list[proc "," 1],proc); }}' | sort -n | tail -n 20 | sort -rn \
| awk '{$1/=1024;printf "%.0fMB\t",$1}{print $2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment