Friday, February 24, 2006

unix tip: sort processes by cpu/memory usage

you can use the following commands to sort processes by cpu/memory usage.

linux
cpu:
# top -bn1P

memory:
# top -bn1M
or just type top without any options, you'll get an interactive interface.

solaris
cpu:
# prstat -s cpu

memory:
# prstat -s size
Read more...

aix
cpu:
# ps -ef | egrep -v "STIME|$LOGNAME" | sort +3 -r | head -n 15

memory:
# svmon -P
summary of the top 15 processes using memory on the system, use the following command:
# svmon -Pt15 | perl -e 'while(<>){print if($.==2||$&&&!$s++);$.=0 if(/^-+$/)}'
or you can just use an topas.

2 comments:

Anonymous said...

Could you please let me know which command do i need for finding the first 10 processes which is using the high memory and cpu on HPUX ??

Thanks a lot.

Regards
murtAza

bartus11 said...

Perl is kind of overkill here. This will do the job just fine:
svmon -Pt15 | nawk '/^-+$/{getline;getline;print}'