Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

ps - report process status

&pagelevel(4)&pagelevel

ps outputs information about active processes. This report represents a snapshot of the system or process status at a given moment and could be outdated within a split-second, so it may not reflect the actual situation by the time it is displayed.


Syntax


ps[ -aAcdeflj][ -g grplist][ -G grplist][ -n namelist][ -o format]...
  [ -p proclist][ -s sesslist][ -t termlist][ -T][ -u userlist][ -U userlist]

No option specified

ps outputs information about processes associated with the current terminal. The output consists of a short listing comprising:

  • the process ID (PID)

  • the terminal identifier (TTY)

  • the cumulative execution time (TIME)

  • the command name (COMD).

The significance of the output columns is explained in the section entitled Output.


-a

Outputs information about all processes associated with a terminal, except process group leaders.

-A

Information about all own processes is output. This option is equivalent to the -e option.

The POSIX administrator is shown information about all processes.

-c

Also outputs information relating to process class and priority.

-d

Outputs information about all processes associated with a terminal as well as those which are not. Process group leaders are not taken into account.

-e

Outputs information about all own processes. This option is equivalent to the -A option.

BS2000:
Only the POSIX administrator is shown information about all processes.
If other users are also to obtain information on all the processes, the POSIX administrator must set the s bit for the /sbin/ps file after POSIX-BC has been installed (command: chmod +s /sbin/ps).

-f

(full list)

Outputs a full listing with supplementary information on each process. The columns displayed in a full listing are explained in more detail in the section entitled Output.

If -f is specified, ps outputs the command name and arguments. However, the arguments are displayed only if the process belongs to the user who called ps, or if ps was called by the POSIX administrator.

If the command name for the process contains non-printing characters, the command name is enclosed within square brackets [...]. If the -f option is specified without other options, the information output refers to processes associated with the controlling terminal.

-g grplist

Restricts listing to data about processes whose process group leaders are given in grplist.

grplist is a list containing the process ID numbers of process group leaders. This list can be specified in one of two forms:

a comma-separated list of numbers, or a list of numbers enclosed in double quotes with the numbers separated by commas and/or blanks.

-G grplist

Information is only output about processes whose real process leader is specified in grplist.

grplist is a list of the process ID numbers of process group leaders. grplist has the following format:

The numbers are separated by commas or the list is enclosed in quotes "...". In the latter case, the numbers may also be separated by commas and/or spaces.

-j

Outputs the session ID and the process group ID.

-l

(long list)

Outputs a long listing with detailed information on each process. The output columns in a long listing are explained in the section entitled Output. If the -l option is specified without other options, the information output refers to processes associated with the controlling terminal.

-n namelist

The system file specified in namelist is used insead of the default file.

-o format

Outputs information in accordance with the definitions specified in format (see the section “User-defined output formats”).

-p proclist

Restricts listing to data about processes whose process ID numbers are given in proclist.

proclist is a list of process ID numbers.

The numbers must be separated by commas, or alternatively, the whole list can be enclosed in double quotes with the numbers separated by commas and/or blanks.

-s sesslist

Restricts listing to data about processes associated with a session listed in sesslist.

sesslist is a list of session ID numbers. This list can be specified in one of two forms:

a comma-separated list of numbers, or a list of numbers enclosed in double quotes with the numbers separated by commas and/or blanks.

-t termlist

Restricts listing to data about the processes associated with the terminals named in termlist.

termlist is a list of terminal identifiers which may be specified in one of two forms: either the device’s file name (e.g. term/tty04) or, if the device’s file name is constructed with tty, just the digit identifier (e.g. 004).

The terminal identifiers must be separated by commas, or alternatively, the whole list can be enclosed in double quotes with the entries separated by commas and/or blanks.

-T  

The BS2000 TSN of the processes is also output. -T can be specified together with other options. -T is effective with all options except -o.

-u userlist

Restricts listing to data about processes whose process owner is given in userlist.

userlist is a list of user ID numbers or login names.

The entries in userlist must be separated by commas or, alternatively, the whole list can be enclosed in double quotes with the entries separated by commas and/or blanks.

-U userlist

Information is only output about processes whose real process leader is specified in userlist.

userlist is a list of user IDs or login names.

The specifications in userlist must be separated by commas, or alternatively, the whole list can be enclosed in double quotes with the entries separated by commas and/or blanks.

Output

The following describes the headings and meanings of the ps output columns if option -o is set. The letters in parentheses indicate the option that causes the corresponding column to appear. all means that the column appears for all options. Note that options -c, -j, -f and -l determine only what information is provided for a process; they do not determine which processes will be listed.

F (l)

Flags (hexadecimal and additive) associated with the process. These flags are machine-dependent and have therefore been omitted here.

S (l)

State of the process.

0: process running

S: Sleeping:

process waiting for an event

R: Runnable:

process is runnable

I: Idle:

process being created

Z: Zombie state:

process is terminated, but its exit status has not yet been queried by the parent with a wait() system call

T: Traced:

traced process stopped by a parent process

X: SXBRK state:

process waiting for more memory

UID ( f, l)

(User ID)

The user ID number of the process owner. If the -f option is set, the login name is output instead of the UID.

Only the first 7 characters of the user ID are output.

PID (all)

(Process ID)

The process ID number of the process. Every process is assigned a unique PID when it is created. You can use this number in a kill command, for example, if you want to terminate a particular process.

TSN (T)

Task sequence number of the BS2000 process (task).

PPID ( f, l)

(Parent Process ID) The process ID of the parent process.

PGID (j)

Process group ID.

SID (j)

Session ID.

C ( f, l)

Processor utilization for scheduling.

CLS (c)

Scheduling class (processes handled by the scheduler).

PRI (l,c)

Priority of the process. Higher numbers normally mean lower priority. However, if the -c option is specified, higher numbers mean higher priority.

NI (l)

Nice value, i.e. value by which process priority was changed (see nice). Only processes in the time-sharing class have a nice value.

ADDR (l)

Core address (physical page frame number) of the user area if resident; the disk address if swapped out.

SZ (l)

Size in blocks of the core image of the process.

WCHAN (l)

Address of the event for which the process is waiting. If the column is blank, the process is running.

STIME ( f)

Starting time of the process. The time is output within the first 24 hours; thereafter, the date.

TTY (all)

The controlling terminal for the process. A question mark (?) is output when there is no controlling terminal.

TIME (all)

The cumulative execution time for the process in minutes and seconds.

COMD (all)

The command name. If the -f option is specified, the full command name and its arguments are output.

Processes which have terminated, but whose exit status has not yet been queried by the parent with a wait() system call, is marked <defunct>.


If termlist, proclist, userlist, or grplist is not specified, ps will try to determine the controlling terminal by checking the standard input, standard output, and standard error in that order. It will then report on the processes associated with the controlling terminal. If the above three channels are all redirected, ps will not find a controlling terminal and hence not produce a report.

User-defined output formats

You can use the option -o format to define your own output (see also example 2). format is a list of variables which can be entered as individual arguments or separated by commas or blanks.

Each variable has a default header. The default header can be renamed, i.e. you can assign it a new text by appending to it the equals sign (=) and the new name.

The variables specified in format are written to the standard output where they appear next to each other. The individual field widths depend on the length of the default header. If the header text is void, e.g. -o user=, then at least the width of the default header is used.

You may specify the following variables in format, the default header shown in brackets is assigned to the variable if no further -o specifications are entered:

ruser (RUSER)

the real login name of the process. If this can be determined and the field width permits it, this is displayed as text, otherwise in decimal form.

user (USER)

the effective login name of the process. If this can be determined and the field width permits it, this is displayed as text, otherwise in decimal form.

rgroup (RGROUP)

the real group ID of the process. If this can be determined and the field width permits it, this is displayed as text, otherwise in decimal form.

group (GROUP)

the effective group ID of the process. If this can be determined and the field width permits it, this is displayed as text, otherwise in decimal form.

pid (PID)

the decimal value of the process ID

ppid (PPID)

the decimal value of the parent process ID

pgid (PGID)

the decimal value of the parent group ID

pcpu (%CPU)

the percentage value of utilized CPU time

vsz (VSZ)

the decimal value of the storage space required by the process in kilobytes

nice (NI)

the decimal value of the system scheduling priority

etime (ELAPSED)

the time the process has been running, specified in [[dd-]hh:]mm:ss

time (TIME)

the total period of CPU utilization for the process

tty (TT)

name of the terminal on which the process is running

comm (COMMAND)

name of the command which is being executed, specified in text form (it may contain
spaces)

args (COMMAND)

command with all spaces, in text form (it may contain spaces)

tsn (TSN)

BS000 TSN (task sequence number) of the process

Variable

COLUMNS

Override the system-selected horizontal screen size, used to determine the number of text columns to display.

Locale

The following environment variables affect the execution of ps:

LANG

Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL

If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE

Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other.

LC_MESSAGES

Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

LC_TIME

Determine the format and contents of the date and time strings displayed.

NLSPATH

Determine the location of message catalogs for the processing of LC_MESSAGES.

Example 1

ps is called with the -l option to display a long listing of information on all active processes on the controlling terminal:

$ ps -l
 F S   UID   PID  PPID  C PRI NI     ADDR     SZ    WCHAN TTY      TIME CMD
10 S   110  1455  1453  0  30 20 c0fec9d8     23 d114f200 term/001  0:02 sh
10 O   110  1862  1455 12  50 20 c0fec870     60          term/001  0:00 ps
18 S   110  1858  1455 10  20 20 c0fecaf8     55 d115f280 term/001  1:03 find

The find command is now to be terminated by calling kill with the process ID number displayed in the PID column. A subsequent call to ps then confirms that the corresponding process no longer exists.

$ kill 1858
$ ps
   PID TTY      TIME COMD
  1455 tty004   0:02 sh
  1873 tty004   0:00 ps
  1858 Terminated

Example 2

User-defined output format of the ps command: output of USER, PID, PPID (if the new name is to contain FATHER) and output of arguments.

$ ps -o user,pid,ppid=FATHER -o args
   USER   PID     FATHER     COMMAND
 HELEN     62          0      [sh]
 HELEN    122         62      [ps]

Example 3

Only the BS2000 TSN of the current shell (without a header) is to be output.

$ ps -o tsn= -p $$

7R6C

By way of comparison:

$ ps -T
   PID  TSN TTY        TIME  CMD
   180 7R69 term/002   0:00  ps
   148 7R6C term/002   0:11  sh

See also

kill, nice