Last active
September 6, 2017 16:29
-
-
Save tiebingzhang/517a8494bc16ba74cf79e103dde46a9f to your computer and use it in GitHub Desktop.
script to sort which process uses the most memory
This file contains 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/sh | |
>/tmp/maxmem.out | |
>/tmp/maxmem2.out | |
for i in /proc/[1-9]* ; do | |
grep -q VmSize $i/status || continue | |
awk '/^VmSize:/{printf("%s ",$2);};' $i/status >> /tmp/maxmem.out | |
awk '/^VmRSS:/{printf("%s ",$2)};' $i/status >> /tmp/maxmem2.out | |
echo -n " $i " >> /tmp/maxmem.out | |
echo -n " $i " >> /tmp/maxmem2.out | |
echo >> /tmp/maxmem.out | |
echo >> /tmp/maxmem2.out | |
done | |
echo "----------------Sorted by VmSize" | |
sort -r -n /tmp/maxmem.out | head -n 10 | |
echo "----------------Sorted by RSS Size" | |
sort -r -n /tmp/maxmem2.out | head -n 10 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment