Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

top - display processes sorted, e.g. by CPU usage

&pagelevel(4)&pagelevel

To monitor POSIX processes or to diagnose problems, top can be used to output a list of all POSIX processes, sorted by CPU usage or other process properties.

The functionality of top differs significantly depending on the type of standard output (stdout):

  • The standard output is not a terminal:
    • top captures data for the duration of the specified measurement interval, outputs the process list, and then terminates.
    • The number of processes in the list and the width of an output line are unlimited.
  • The standard output is a BS2000 block terminal:
    • top captures data for the duration of the specified measurement interval, outputs the process list, and then terminates.
    • The list displays a maximum of 18 processes, allowing the entire output to be displayed on the terminal without overflow.
    • The width of an output line is limited to a maximum of 79 characters to avoid line breaks.
  • The standard output is a character terminal:
    • top captures data for a short interval (approx. 1 second) and displays the process list. As long as the user does not terminate top, measurement data is periodically recorded according to the specified measurement interval and the process list display is updated.
    • The column by which the process list is sorted is highlighted.
    • The maximum number of processes in the list and the width of an output line are limited by the geometry of the terminal window. top detects dynamic changes to the window geometry and adjusts its output accordingly. The terminal window must have at least 80 columns and 24 rows; otherwise, top will terminate with an error message.
    • The user can interactively control the behavior of top using commands.


By default, only the POSIX administrator (superuser) runs top with superuser privileges, which is a prerequisite for displaying all POSIX processes.

If other users should also be allowed to run top with superuser privileges, the POSIX administrator can allow these users to execute "sudo top ..." (see sudo, sudoers).

Alternatively, after installing POSIX-BC, the POSIX administrator can assign the S-bit to the command (using: chmod +s /sbin/top) so that all users execute top with superuser privileges.


Syntax


top[ -i interval][ -o order][ -r][ -u username][ -s]

No option specified

top outputs a list of processes sorted by CPU usage in descending order. The measurement interval is 5 seconds.


-i interval

This option specifies the length of a measurement interval in seconds (minimum 1, maximum 60, default value 5).

-o order

This option specifies the process property by which the list should be sorted.

One of the following process properties can be specified, with no distinction between uppercase and lowercase letters:

CPU
The percentage ratio of CPU time consumed by the process within the measurement interval to the length of the measurement interval. This process property is used for sorting by default.

PCPU
Percentage ratio of the total CPU time consumed by the process to the total runtime of the process (see the -o pcpu option of the ps command).

TIME
Total CPU time consumed by the process.

SIZE
Memory used by the process (only in the user address space).

PID
Process number (process ID) of the process.

-r

This option reverses the sort order. By default, the process list is sorted in descending order according to the selected process property.

-u username

This option requires superuser privileges. It specifies that only processes belonging to the specified user are displayed. By default, processes of all users are displayed.

-s

This option requires superuser privileges. It specifies that system processes (system tasks) are also displayed. By default, only user processes (user tasks) are displayed.

Output

The output screen of top consists of the following lines:

  • Line 1:
    Status line with the current time and system information.

  • Line 2:
    Status line containing:
    • Process property by which the list is sorted (see the -o option). The suffix "/r" indicates that the reverse sort order applies.
    • Length of the measurement interval.
    • Hint text "Enter: h=help, q=quit", if the standard output is a character terminal.

  • Line 3:
    Output line for messages from top.
    Input line for interactive commands, if the standard output is a character terminal.

  • Line 4:
    Header of the process list

  • From line 5 onwards:
    Process list

The process list consists of the following columns:

  • PID
    Process number (process ID) of the process.

  • USER
    Username of the process.

  • TSN
    Task Sequence Number (TSN) of the process.

  • SIZE
    Memory allocated by the process (only in the user address space).

  • TIME
    Total CPU time consumed by the process.

  • PCPU
    Percentage of CPU time consumed by the process relative to the total process runtime.

  • CPU
    Percentage of CPU time consumed by the process during the measurement interval relative to the length of the measurement interval.

  • COMMAND
    Command (program) executed by the process.

Interactive commands

In interactive mode, i.e., if the standard output is a character terminal, the following commands are available:

ispecify interval between screen updates (measurement interval)
uselect processes of one user(*)
ospecify sort order
sdisplay/hide system processes(*)
renable/disable reverse sort order
<blank>update the screen
hshow help
qquit top

(*) These commands are only available with superuser privileges.

Error messages

Periodic display impossible
The standard output is not a terminal.

Periodic display impossible on BLOCK terminal
The standard output is a BS2000 block terminal.

Superuser privileges required to show all processes
top runs without superuser privileges. Only processes of the caller's user ID are displayed.

Screen too small: nxn, must be 80x24 at least
The terminal window is too small.

Locale

The following environment variables affect the execution of top:

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.

Example 1

Output of the process list on a BS2000 block terminal:

# top -i 10 -o size ...

[15:43:41]   TOP on BS2000 server D017ZE38 (POSIX-BC 21.0A A49 /390)
Sorted by SIZE, interval 10 sec.
Periodic display impossible on BLOCK terminal.
  PID  USER       TSN   SIZE    TIME    PCPU    CPU  COMMAND
  270  ROOT      160B  4540K    0:15    0.0%   0.0%  [[sshd]: froede@pts|1]
  418  ROOT      164N  4408K    0:02    0.0%   0.0%  [[sshd]: froede@pts|3]
  457  ROOT      165T  4408K    0:00    0.0%   0.0%  [[sshd]: tsos@pts|5]
  194  ROOT      16X1  4343K    0:00    0.0%   0.0%  [[sshd]: |opt|TCP-IP-SV|op
    1  ROOT      16SV   724K    0:00    0.0%   0.0%  [init]
    :
   81  ROOT      16UT   487K    0:00    0.0%   0.0%  [rpcbind]
  135  ROOT      16WC   416K    0:00    0.0%   0.0%  [pcnfsd]

Example 2

Output of the process list on a character terminal:

# top -i 10 -o time -s  ...

[15:55:15]   TOP on BS2000 server D017ZE38 (POSIX-BC 21.0A A49 /390)
Sorted by TIME, interval 10 sec. Enter: h=help, q=quit.

  PID  USER       TSN   SIZE    TIME    PCPU    CPU  COMMAND
    3  ROOT      XPJB     0K    0:37    0.0%   0.0%  fsflush
   13  ROOT      XPJL     0K    0:18    0.0%   0.0%  timerd
  270  ROOT      160B  4540K    0:15    0.0%   0.0%  [[sshd]: froede@pts|1]
  496  ROOT      166X   425K    0:05    1.2%   0.0%  [top]
    0  ROOT      HT24     0K    0:04    0.0%   0.0%  dssm
    :
  126  ROOT      16V3   408K    0:00    0.0%   0.0%  [nfsd]
  127  ROOT      16V4   408K    0:00    0.0%   0.0%  [nfsd]

Example 3

Help screen in interactive mode (command 'h'):

h ...

TOP for POSIX/BS2000

Single-character commands of TOP:

  i        : specify interval between screen updates
  u        : select processes of one user (* = all users)
  o        : specify sort order (see below)
  s        : display/hide system processes
  r        : enable/disable reverse sort order
  <blank>  : update the screen
  h        : show this help
  q        : quit TOP

Sort orders: PID, SIZE, TIME, PCPU, CPU


Press any key to return

See also

ps, pstree