One-liner of the day

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.

Comments

Display comments as (Linear | Threaded)

  1. Anonymous says:

    Or like the rest of the world, you'd run prstat which puts top to shame.

  2. Andre Naumann says:

    *But it works on HP-UX as well and I prefer generic tools :-)

    Ok, honestly, it's been a while since I was taking care of sun computers and I didn't remember.


Add Comment


Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Pavatar/Gravatar/Favatar/MyBlogLog author images supported.