Memory Usage by Bytes Top 10
I need a way to see how many bytes to top ten processes are using not percentage. I am using centos
Solution 1:
it would be better to use ps with head
ps aux --sort -rss | head -10
The RSS
field shows physical memory usage in KB.
Solution 2:
I just notice that rss
is in kiloBytes.
I created an awk
script to print sizes in human readable format:
#!/usr/bin/awk
{
hr[1024**2]="GB"; hr[1024]="MB";
for (x=1024**3; x>=1024; x/=1024) {
if ($1>=x) {
printf ("%-6.1f %s ", $1/x, hr[x]); break
}
}
}
{ printf ("%-6s %-10s ", $2, $3) }
{ for ( x=4 ; x<=NF ; x++ ) { printf ("%s ",$x) } print ("") }
and pipe the ps
output to:
$ ps --no-headers -eo rss,pid,user,command --sort -rss | head -10 | awk -f topmem.awk