[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

ps

Report process status (POSIX)

Syntax:

ps [-Aa] [-G grouplist] [-o format]...
   [-p proclist] [-t termlist] [-U userlist]

Options:

-A
Print information for all accessible processes.
-a
Print information for all processes associated with terminals except for process group leaders.
-G grouplist
Write information for processes whose real group ID is given in grouplist. You can delimit the group IDs with commas or spaces.
-o format
Write information according to the specifications given in format. If you specify more than one -o option, they're treated as a concatenation of all their format arguments.
-p proclist
Print information only for processes whose process IDs are listed in proclist. You can delimit the process IDs with commas or spaces.
-t termlist
Print information only for processes associated with the terminals listed in termlist You can delimit the terminal identifiers with commas or spaces.
-U userlist
Print information only for processes whose real user ID or login name is given in userlist. You can delimit the user IDs with commas or spaces.

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, you'll probably need to quote 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 the -o 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 -o '%+"PID"p %+"TTY"y %+"TIME"t %+"COMMAND"C'

Exit status:

0
Successful completion.
>0
An error occurred.

See also:

pidin

Fine-Tuning Your System in the Neutrino User's Guide


[Previous] [Contents] [Index] [Next]