Wednesday, August 13, 2008

How to make efficient use of "ps" command?

Here is how we can use ps command in Solaris & Redhat Linux to get the details of processes running on system:

- In Solaris use ps from /usr/bin/ps

- In Linux, use ps from /bin/ps





# ps -eo s,pid,ppid,user,group,rss,vsz,pcpu,pmem,time,etime,tty,args
S PID PPID USER GROUP RSS VSZ %CPU %MEM TIME ELAPSED TT COMMAND
T 0 0 root root 0 0 0.0 0.0 00:03 21-18:38:05 ? sched
S 1 0 root root 1920 2512 0.0 0.1 00:05 21-18:38:05 ? /sbin/init
S 2 0 root root 0 0 0.0 0.0 00:00 21-18:38:05 ? pageout
S 3 0 root root 0 0 0.3 0.0 01:22:51 21-18:38:05 ? fsflush
S 203 1 daemon daemon 2160 2456 0.0 0.1 00:00 21-18:37:49 ? /usr/lib/nfs/lockd
S 7 1 root root 9904 12960 0.0 0.2 00:30 21-18:38:03 ? /lib/svc/bin/svc.startd
S 9 1 root root 9704 10384 0.0 0.2 00:38 21-18:38:03 ? /lib/svc/bin/svc.configd
S 183 1 daemon daemon 2360 2848 0.0 0.1 00:10 21-18:37:50 ? /usr/sbin/rpcbind
S 113 1 root root 2856 5768 0.0 0.1 00:00 21-18:37:54 ? /usr/lib/picl/picld
S 197 7 root root 1624 2120 0.0 0.1 00:01 21-18:37:49 ? /usr/lib/saf/sac -t 300
S 190 1 daemon daemon 2432 2752 0.0 0.1 00:00 21-18:37:50 ? /usr/lib/nfs/statd
S 205 197 root root 1888 2392 0.0 0.1 00:01 21-18:37:49 ? /usr/lib/saf/ttymon
S 192 1 root root 2232 2456 0.0 0.1 00:00 21-18:37:50 ? /usr/lib/netsvc/yp/ypbind
S 253 251 root root 3160 7464 0.0 0.1 00:07 21-18:37:49 ? /usr/lib/autofs/automountd
S 121 1 daemon daemon 3528 6944 0.1 0.1 00:01 21-18:37:54 ? /usr/lib/crypto/kcfd
S 119 1 root root 4232 4576 0.0 0.1 01:10 21-18:37:54 ? /usr/sbin/nscd
S 202 1 root root 1176 1360 0.0 0.0 00:04 21-18:37:49 ? /usr/lib/utmpd
S 104 1 root root 2080 4856 0.0 0.1 00:00 21-18:37:54 ? /usr/lib/sysevent/syseventd
O 629 626 root root 3576 10536 0.0 0.1 00:00 00:04 ? /usr/lib/ssh/sshd
S 239 1 root root 1712 5000 0.0 0.1 00:00 21-18:37:49 ? /usr/sbin/cron
S 238 1 root root 4664 7888 0.0 0.1 00:25 21-18:37:49 ? /usr/lib/inet/inetd start
S 251 1 root root 2720 7120 0.0 0.1 00:00 21-18:37:49 ? /usr/lib/autofs/automountd
S 631 629 root root 1592 3736 0.0 0.1 00:00 00:04 pts/1 -ksh
S 267 1 root root 2584 6120 0.0 0.1 00:02 21-18:37:48 ? /usr/sbin/syslogd
S 626 299 root root 6616 10984 0.1 0.1 00:00 00:09 ? /usr/lib/ssh/sshd
S 288 1 root root 1448 2168 0.0 0.1 00:00 21-18:37:48 ? /usr/lib/ldoms/drd
S 299 1 root root 2528 6320 0.0 0.1 00:00 21-18:37:48 ? /usr/lib/ssh/sshd
S 302 1 root root 9400 15000 0.0 0.2 00:23 21-18:37:48 ? /usr/lib/fm/fmd/fmd

=========================================================================
A brief explanation of output:
=========================================================================
S: State of the process
-----------> S: Sleeping,
-----------> O: Runing on processor,
-----------> R: Runnable (it is in run queue),
-----------> Z: Zombie,
-----------> T: Stopped process (either by a job control signal or because it is being traced)
PID: Process ID
PPID: Parent process ID
USER: User name who initiated process
GROUP: Group name from whom user belong/currently launched the job
RSS: The resident set size of the process, in kilobytes.
VSZ:The total size of the process in virtual memory, in kilobytes.
%CPU: Total % of CPU taken by this process
%MEM: Total % of Memory taken by this process
TIME: the cumulative CPU time of the process in the form
ELAPSED: Total time elapsed since this process is live
TT: Terminal ID
COMMAND: Command/daemon/process with args
=========================================================================

No comments: