DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

ps(C)


ps -- report process status

Syntax

ps [ option [ arguments ] ... ]

Description

The ps command prints information about active processes. By default, ps selects all processes with the same effective user ID as the current user and the same controlling terminal as the invoker. Output consists of a short listing containing only the process ID, terminal identifier, cumulative execution time, and the command name. Otherwise, the information that is displayed is controlled by the selection of options.

options accept names or lists as arguments. Separate the individual arguments to an option using commas, or enclose the entire argument list in double quotes and separate the individual arguments using commas or spaces. Values for proclist and grplist must be numeric.

ps takes the following options:


-a
Print information about all processes most frequently requested: all those except session leaders and processes not associated with a terminal.

-A
Print information about all processes (equivalent to -e).

-d
Print information about all processes except session leaders.

-e
Print information about all processes (equivalent to -A).

-f
Generate a full listing (see ``Full and long listings'').

-g grplist
List only process data whose process group leader ID numbers appear in grplist. (A group leader is a process whose process ID number is identical to its process group ID number. A login shell is a common example of a process group leader.)

-G grplist
List only process data whose real group ID numbers are given in grplist.

-l
Generate a long listing (see ``Full and long listings'').

-n name
Valid only for users with a real user ID of root or a real group ID of sys. Takes argument signifying an alternate system name in place of /unix. This option is used when the kernel has been relinked and the executable file /unix does not correspond to the kernel loaded into memory. In this case, the argument is the filename of the UNIX executable that was loaded when the machine was last booted; for example, /unix.old.

-o format
List process data in the specified format. Multiple -o options can be specified on the command line.

format is a comma or whitespace separated list of field names; the list must be placed in quotation marks if whitespace separation is used. ps displays the fields in the order specified on the command line.

You can override the default header for a field by appending a ``='' and the new header text to the field name:

-o field=header

If the header text contains whitespace, enclose the entire field=header string in quotation marks and specify it using a separate -o option:

-o "field=header"

You can prevent a header from being displayed for an individual field by not specifying it after the ``=''. If all field names have a single ``='' appended but no header text, no header line is displayed at all.

ps changes the field width from its default value to match the width of the specified header text.

Allowed field names follow (default headers are shown in parentheses):


pid
Process ID as a decimal value. (PID)

ppid
Parent process ID as a decimal value. (PPID)

pgid
Process group ID as a decimal value. (PGID)

uid
Real user ID of the process as a decimal value. (UID)

user
The effective user ID of the process. (USER)

ruser
Real user ID of the process. (RUSER)

comm
Command name; may contain spaces. (COMMAND)

args
Command name with its arguments; may contain spaces and may be truncated to fit the width of the field. (COMMAND)

group
Effective group ID of the process. (GROUP)

rgroup
Real group ID of the process. (RGROUP)

nice
nice value of the process; see nice(C) and renice(C). (NI)

pri
Priority value of the process. (PRI)

pcpu
Percentage of CPU time recently used by the process. (%CPU)

sess
Process session leader ID as a decimal value. (SESSION)

size
Size of the swappable image of the process (data and stack) in kilobytes. (SZ)

vsz
Virtual memory size of the process in kilobytes. (VSZ)

addr
Virtual address of the process' entry in the process table. (ADDR)

class
Scheduler class of the process. (CLASS)

time
Cumulative CPU time used by the process. (TIME)

stime
Time when the process started. (STIME)

etime
Time elapsed since the process started. (ELAPSED)

tty
Name of the controlling terminal for the process. (TTY)

wchan
Address of an event for which a process is sleeping. (WCHAN)

For fields user, ruser, group, and rgroup, ps displays the user or group name if it can be obtained and it will fit in the field. Otherwise it displays the decimal value of the ID.


-p proclist
List only process data whose process ID numbers are given in proclist.

-t termlist
List only process data associated with the terminal given in termlist. Terminal identifiers may be specified in one of two forms: the device's filename (for example, tty04) or, if the device's filename starts with tty, just the digit identifier (for example, 04).

-u uidlist
List only process data whose user ID numbers or login names appear in uidlist. In the listing, the numerical user ID will be printed unless you give the -f option, which prints the login name.

-U uidlist
List only process data whose real user ID numbers or login names are given in uidlist.

Full and long listings

Under the -f option, ps tries to determine the command name and arguments given when the process was created by examining the user block. Failing this, the command name is printed, as it would have appeared without the -f option, in square brackets.

The column headings and the meaning of the columns in a ps listing are given in the following text; the letters -f and -l indicate the option (full or long, respectively) that causes the corresponding heading to appear; if no option letter is given, the heading always appears. Note that these two options determine only what information is provided for a process; they do not determine which processes will be listed.


F (-l)
Octal flags which are added together to give more information about the current status of a process:

00
If shown on its own, the process has terminated; its process table entry is now available.

01
A system process which is part of the kernel and always resident in primary memory. sched (the swapper), vhand (the pager), and bdflush (the buffer cache manager) are all system processes.

02
Parent is tracing process.

04
Tracing parent's signal has stopped the process; the parent is waiting ( ptrace(S)).

10
Process is sleeping at less than or equal to priority 25 and cannot be awakened by a signal; for example, while waiting for an inode to be created.

20
Process is loaded in primary memory; it has not been swapped out to disk.

40
Process is currently locked in primary memory and cannot be swapped out until an event completes; for example, while performing raw I/O.

S (-l)
The state of the process:

O
Process is running on a processor (SONPROC).

S
Sleeping: process is waiting for an event to complete (SSLEEP).

R
Runnable: process is on run queue (SRUN).

I
Idle: process is being created (SIDL).

Z
Zombie state: process terminated and parent not waiting (SZOMB).

T
Traced: process stopped by a signal because parent is tracing it (SSTOP).

B
Process is waiting for more pages of memory to become available (SXBRK).

UID (-f, -l)
The user ID number of the process owner (the login name is printed under the -f option).

PID
The process ID of the process (this number is needed in order to kill a process).

PPID (-f, -l)
The process ID of the parent process.

C (-f, -l)
An estimate of recent CPU usage by the process; the scheduler combines this quantity with the nice value of the process to calculate its priority.

PRI (-l)
The priority of the process (lower numbers mean lower priority). Processes with priorities in the range 0 to 65 are in user mode and may be selected by the scheduler to run. Processes with priorities between 66 and 95 are sleeping in system mode while waiting for a system resource to become available. If their priority is between 77 and 95, they are also immune to signals while protecting critical data structures. The swapper (sched) sleeps at priority 95. Processes with priorities between 96 and 127 are fixed priority processes.

NI (-l)
The nice value of the process; see nice(C) and renice(C).


ADDR (-l)
The virtual address of the process' entry in the process table.

SZ (-l)
The swappable size (in kilobytes) of the virtual data and stack segments of the process.

WCHAN (-l)
An address that uniquely identifies a process within the process table as sleeping until a particular resource becomes available; for example, until an I/O request has been completed, or in an SXBRK state until more pages of memory are available.

STIME (-f)
The starting time of the process, given in hours, minutes, and seconds. (A process begun more than twenty-four hours before ps is executed is given in months and days.)

TTY
The controlling terminal for the process (the message ``?'' is printed when there is no controlling terminal).

TIME
The cumulative execution time for the process.

CMD
The name of the command corresponding to the process. The -f option prints the full command name and its arguments.
A process that has exited and has a parent, but has not yet been waited for by the parent, is marked <defunct>.

ps displays a ``-'' in a field if the process does not have a meaningful value for the field.

Examples

Display the processes you are running:

ps

If you are using multiscreens or several terminals connected to one machine, the following displays your processes:

ps -u $LOGNAME

Page a long listing of all processes to the screen:

ps -Al | pg

Show full details of processes that belong to janet and john:

ps -fu "janet john"

Create a customized listing of janet and john's processes showing the user ID, command line, process ID, and process virtual memory size. The headings LONG COMMAND, PROCESS ID, and VM SIZE replace the default headings:

ps -u janet,john -o user -o "args=LONG COMMAND" \
-o "pid=PROCESS ID"-o "vsz=VM SIZE"

Quotation marks around the format definitions are needed because the headers contain whitespace. This also means that each individual field header must be defined using the -o option.

Display in decreasing order, the IDs and percentage CPU usage of all processes where usage is more than 5% of CPU time:

ps -A -o "pid=" -o "pcpu=" | awk '$2 > 5 {print $1" "$2}' | sort -r +1

Limitations

Things can change while ps is running; the snap-shot it gives is only true for a split-second, and it may not be accurate by the time you see it. Some data printed for defunct processes is irrelevant.

If no termlist, proclist, uidlist, or grplist is specified, ps checks stdin, stdout, and stderr in that order, looking for the controlling terminal and will attempt to report on processes associated with the controlling terminal. In this situation, if stdin, stdout, and stderr are all redirected, ps will not find a controlling terminal, so there will be no report.

On a heavily loaded system, ps may report an lseek(S) error and exit. ps may seek to an invalid user area address: having obtained the address of a process' user area, ps may not be able to seek to that address before the process exits and the address becomes invalid.

ps -ef may not report the actual start of a tty login session, but rather an earlier time, when a getty was last respawned on the tty line.

Authorization

The behavior of this utility is affected by assignment of the mem authorization in authorize(F). If you do not have this authorization, the output will be restricted to data pertaining to your activities only. Refer to subsystem(M) for more details.

Files


/dev/tty*
terminal (``tty'') names searcher files

/dev/kmem
kernel virtual memory

/dev/swap
the default swap device

/dev/mem
memory

/etc/passwd
UID information supplier

/etc/ps/ps_data
internal data structure

/etc/ps/syms.*
list of kernel symbols

/etc/ps/ttys
list of character special devices

/etc/ps/uids
list mapping user IDs to user names

/etc/ps/gids
list mapping group IDs to group names

/unix
system name list

See also

getty(M), kill(C), lseek(S), nice(C), renice(C), subsystem(M)

Standards conformance

ps is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992;
X/Open CAE Specification, Commands and Utilities, Issue 4, Version 2, 1994..


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003