ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'| head -10

   1243.09 Mb /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
      1151.62 Mb /usr/bin/python /usr/bin/fail2ban-server -b -s /var/run/fail2ban/fail2ban.sock -p /var/run/fail2ban/fail2ban.pid
       255.69 Mb /usr/bin/tor --defaults-torrc /usr/share/tor/tor-service-defaults-torrc --hush
       217.24 Mb /usr/sbin/rsyslogd -n
       168.89 Mb /usr/sbin/named -f -u bind
       122.74 Mb /usr/sbin/apache2 -k start
       122.64 Mb /usr/sbin/apache2 -k start
       120.48 Mb /usr/sbin/apache2 -k start
       120.45 Mb /usr/sbin/apache2 -k start

script it

this way you can pass it how many processes you would like to view – it auto updates every 3 seconds.

vim /scripts/mon_ram.sh

#!/bin/bash

while true ; do

ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'| head -$1

sleep 3;

clear;

done
admin