One-liner of the day

Wednesday, February 20. 2008
Need something like top on a Solaris machine which hasn't installed top?

Try this, most active processes should be at the bottom of the list:

while true; do clear; ps -o pcpu,pid,ppid,user,comm -ef | sort -n | grep -v PPID; echo; date; sleep 2; done


lines are sorted by CPU usage which can be found in the first column. The other columns show process id, parent process id, user and the command running like this:


0.0 26012 686 root /usr/local/openssh/sbin/sshd
0.0 26015 26012 root -sh
0.0 26561 1 root vmstat
0.0 27084 637 root sh
0.0 27085 27084 root /bin/ksh
0.0 27086 27085 root sleep
0.0 27094 26015 root grep
0.0 27095 27094 root ps
0.0 27096 27094 root sort
0.1 1 0 root /etc/init
0.1 479 1 root /opt/VRTSob/bin/vxsvc
0.1 522 1 root /usr/lib/netsvc/yp/ypserv
0.1 623 1 root /usr/lib/autofs/automountd
0.1 17621 1 root /usr/sbin/nscd
0.4 3 0 root fsflush

Wed Feb 20 13:15:01 MET 2008


Not the best way, but good enough for a quick estimation.