[Previous] [Contents] [Next]

ps

Report process status (POSIX)

Syntax:

ps [options]...

Options:

-A
Print information for all accessible processes.
-a
Print information for all processes associated with terminals except for process group leaders.
-d
(QNX extension) Print information for all processes except process group leaders.
-e
(QNX extension) Print in long format showing elapsed time (equivalent to -F "%p %r %N %S %b %T %a").
-F format
(QNX extension) Print information according to the format specifications given in format.
-G grouplist
Not supported in QNX 4.24. See -g.
[-g gid[,gid]...
(QNX extension) Print information only for processes whose group IDs are listed.
-l
("el" -- QNX extension) Print in long format (equivalent to -F "%p %r %N %S %b %x %a").
-n node
(QNX extension) Print information only for processes on the specified node.
-o format
Not supported in QNX 4.24. See -F.
-p pid[,pid]...
Print information only for processes whose process IDs are listed.
-s sid[,sid]...
(QNX extension) Print information only for processes whose session IDs are listed.
-S state[,state]...
(QNX extension) Print information only for processes whose states are listed. (e.g. READY, WAIT).
-t sid[,sid]...
Print information only for processes associated with the terminals listed. Terminals must be in the form [nid]tty_basename, where nid is the node the device exists on, and tty_basename is the basename portion of the controlling terminal's pathname. (e.g. [3]con1 for //3/dev/con1)
-U userlist
Not supported in QNX 4.24. See -u.
-u uid[,uid]...
(QNX extension) Print information only for processes whose user IDs are listed.

Description:

The ps utility prints information about processes, subject to having the appropriate privilege to obtain information about those processes. With no options, ps prints information about processes associated with the current terminal. The output includes the process ID, terminal name, cumulative execution time, and command name of each process.

The options that use lists (-g, -p, -t, -u) can list multiple items separated by commas or white space, as long as all the items are contained within a single command-line argument. If white space is used, this will require quoting the list when invoking ps from the shell.

The initial set of processes selected by -a, -A, or -d is intersected with the processes selected by the -g, -p, -t, or -u options, if any of the latter are specified.

If none of -a, -A, or -d is specified, ps behaves as though you specified -u your_uid.

Controlling output

To control the content and format of output, you use -F format option, which takes any of the field descriptors listed below. All of these field descriptors, with the exception of %% and %a, are of the form:

The + forces right justification; the - forces left justification. If neither + nor - is specified, the default justification for the descriptor is used. If no title is given for a field, spaces are printed. The [ and ] aren't part of the descriptor; they simply show the optional parts of the descriptor.

The %a field descriptor has the form:

You can use the optional width for limiting the length of what is printed for this field.

Any text included between the field descriptors is printed on all lines, including the header line.

Field descriptors:

%%
A literal % character.
%a
The command with all its arguments as a string.
%b
The process that this process is blocked on.
%c
The name of the command (argv[0] value) as a string.
%C
The ratio of CPU time used (%x) to CPU time available, expressed as a percentage.
%d
The current working directory of the process.
%e
The initial environment of the process.
%f
The flags of the process.
%g
The real group ID of the process.
%G
The effective group ID of the process.
%p
The decimal value of the process ID.
%P
The decimal value of the parent process ID.
%n
The decimal value of the process's nice value.
%N
The decimal value of the process's priority.
%r
The decimal value of the process group ID.
%s
The decimal value of the session ID.
%S
The process state of the process.
%t
In the POSIX locale, the elapsed wall clock time of the process in the form:

[dd-]HH:MM:SS

The dd field is not shown if less than one day.

%T
In the POSIX locale, the relative start time of the process in the form: The dd field gives the number of days before the current date that have elapsed since the process started (not shown if dd is less than one day).
%u
The real user ID of the process. If the user ID is present in the /etc/passwd file, a textual user name is printed; otherwise, a decimal numeric user ID is printed.
%U
The effective user ID of the process (see %u).
%x
In the POSIX locale, the cumulative CPU time of the process in the form: The dd field is not shown if less than one day.
%y
If a controlling terminal is present, the name of the terminal, consisting of the node ID followed by the basename of the device pathname.
%z
The size of the process in (virtual) memory in kilobytes, expressed as a decimal integer. Shared code or segments are not accounted for.

Examples:

Emulate the default output from a System V ps command:

ps -F '%+"PID"p %+"TTY"y %+"TIME"t %+"COMMAND"C'

Exit status:

0
Successful completion.
>0
An error occurred.

See also:

sin


[Previous] [Contents] [Next]