PDA

View Full Version : Linux: Show memory usage per process - each process memory usage sorted



Fli
08-31-2014, 11:50 AM
Hello,

do You know any simple ways to read processes memory usage for each process, preferably in Megabytes (human readable format)?

I found so far these commands which show memory usage per process:

1

ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS


432 vzctl: pts/1
656 pr -TW126
760 /bin/sh /usr/bin/mysqld_safe
776 sort -b -k1,1n
936 ps -e -orss=,args=
2020 -bash
5052 init
6108 /usr/sbin/apache2 -k start
6116 /usr/sbin/apache2 -k start
6176 /usr/sbin/apache2 -k start
6460 /usr/sbin/apache2 -k start
6460 /usr/sbin/apache2 -k start
6468 /usr/sbin/apache2 -k start
14184 /usr/sbin/apache2 -k start
33452 /usr/sbin/mysqld
45396 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/va

2

ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 10


13390 2.1 /usr/sbin/mysqld
21811 1.5 /usr/sbin/mysqld
22065 0.6 /usr/sbin/apache2
22066 0.3 /usr/sbin/apache2
22068 0.3 /usr/sbin/apache2
22073 0.3 /usr/sbin/apache2
1 0.2 init
22067 0.2 /usr/sbin/apache2
22069 0.2 /usr/sbin/apache2
22077 0.2 /usr/sbin/apache2

3

or "top -c" and then Shift + M (sort processes by memory usage, and it shows also m (as megabytes)