3.3. Process Status: psThe standard command to list process information is ps, process status. Solaris ships with two versions: /usr/bin/ps, which originated from SVR4; and /usr/ ucb/ps, originating from BSD. Sun has enhanced the SVR4 version since its inclusion with Solaris, in particular allowing users to select their own output fields. 3.3.1. /usr/bin/ps CommandThe /usr/bin/ps command lists a line for each process. $ ps -ef UID PID PPID C STIME TTY TIME CMD root 0 0 0 Feb 08 ? 0:02 sched root 1 0 0 Feb 08 ? 0:15 /sbin/init root 2 0 0 Feb 08 ? 0:00 pageout root 3 0 1 Feb 08 ? 163:12 fsflush daemon 238 1 0 Feb 08 ? 0:00 /usr/lib/nfs/statd root 7 1 0 Feb 08 ? 4:58 /lib/svc/bin/svc.startd root 9 1 0 Feb 08 ? 1:35 /lib/svc/bin/svc.configd root 131 1 0 Feb 08 ? 0:39 /usr/sbin/pfild daemon 236 1 0 Feb 08 ? 0:11 /usr/lib/nfs/nfsmapid ... ps -ef prints every process (-e) with full details (-f). The following fields are printed by ps -ef:
For reference, Table 3.2 lists useful options for /usr/bin/ps.
Many of these options are straightforward. Perhaps the most interesting is -o, with which you can customize the output by selecting which fields to print. A quick list of the selectable fields is printed as part of the usage message. $ ps -o ps: option requires an argument -- o usage: ps [ -aAdeflcjLPyZ ] [ -o format ] [ -t termlist ] [ -u userlist ] [ -U userlist ] [ -G grouplist ] [ -p proclist ] [ -g pgrplist ] [ -s sidlist ] [ -z zonelist ] 'format' is one or more of: user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid ctid pri opri pcpu pmem vsz rss osz nice class time etime stime zone zoneid f s c lwp nlwp psr tty addr wchan fname comm args projid project pset The following example demonstrates the use of -o to produce an output similar to /usr/ucb/ps aux, along with an extra field for the number of threads (NLWP). $ ps -eo user,pid,pcpu,pmem,vsz,rss,tty,s,stime,time,nlwp,comm USER PID %CPU %MEM VSZ RSS TT S STIME TIME NLWP COMMAND root 0 0.0 0.0 0 0 ? T Feb_08 00:02 1 sched root 1 0.0 0.1 2384 408 ? S Feb_08 00:15 1 /sbin/init root 2 0.0 0.0 0 0 ? S Feb_08 00:00 1 pageout root 3 0.4 0.0 0 0 ? S Feb_08 02:45:59 1 fsflush daemon 238 0.0 0.0 2672 8 ? S Feb_08 00:00 1 /usr/lib/nfs/statd ... A brief description for each of the selectable fields is in the man page for ps. The following extra fields were selected in this example:
The -o option also allows the headers to be set (for example, -o user=USERNAME). 3.3.2. /usr/ucb/psThis version of ps is often used with the following options. $ /usr/ucb/ps aux USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND root 3 0.5 0.0 0 0 ? S Feb 08 166:25 fsflush root 15861 0.3 0.2 1352 920 pts/3 O 12:47:16 0:00 /usr/ucb/ps aux root 15862 0.2 0.2 1432 1048 pts/3 S 12:47:16 0:00 more root 5805 0.1 0.3 2992 1504 pts/3 S Feb 16 0:03 bash root 7 0.0 0.5 7984 2472 ? S Feb 08 5:03 /lib/svc/bin/svc.s root 542 0.0 0.1 7328 176 ? S Feb 08 4:25 /usr/apache/bin/ht root 1 0.0 0.1 2384 408 ? S Feb 08 0:15 /sbin/init ... Here we listed all processes (a), printed user-focused output (u), and included processes with no controlling terminal (x). Many of the columns print the same details (and read the same procfs values) as discussed in Section 3.3.1. There are a few key differences in the way this ps behaves:
$ /usr/ucb/ps aux USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND user1 3132 5.2 4.33132422084 pts/4 S Feb 16 132:26 Xvnc :1 -desktop X user1 3153 1.2 2.93544414648 ? R Feb 16 21:45 gnome-terminal --s user1 16865 1.0 10.87992055464 pts/18 S Mar 02 42:46 /usr/sfw/bin/../li user1 3145 0.9 1.422216 7240 ? S Feb 16 17:37 metacity --sm-save user1 3143 0.5 0.3 7988 1568 ? S Feb 16 12:09 gnome-smproxy --sm user1 3159 0.4 1.425064 6996 ? S Feb 16 11:01 /usr/lib/wnck-appl ... This can make both reading and postprocessing the values quite difficult. |