At times, you wish to find the processes with maximum memory consumption. This can be easily done using following command. Copy contents in file and run it like as vmstat command
### Usage mem_mon.sh (interval) (occurences) e.g sh mem_mon.sh 2 10 ###
### This will give top 10 memory consuming processes #####
wt_time=$1
lmt=$2
let a=0
while [[ $a -lt $lmt ]] ; do
ps axwv |sort -nrk 7,7|grep -v "COMMAND" \
|awk 'BEGIN {printf ("MemoryinKb \t ProcessId \t PerCPU \t PerMem \t Command \n")}{t=t+$7 - $10 ;printf("%13d \t %10d \t %6.2f \t %6.2f \t %s \n",$7 - $10,$1,$11,$12,$13)}END{print t}'|head -10
let a+=1
sleep $wt_time
done
Posted 11 months ago
#



