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.
This option specifies the length of a measurement interval in seconds (minimum 1, maximum 60, default value 5).
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:
This option reverses the sort order. By default, the process list is sorted in descending order according to the selected process property.
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.
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:
|
The process list consists of the following columns:
|
Interactive commands
In interactive mode, i.e., if the standard output is a character terminal, the following commands are available:
(*) These commands are only available with superuser privileges. | |||||||||||||||||||||||||
Error messages
|
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:
|
Example 2
Output of the process list on a character terminal:
|
Example 3
Help screen in interactive mode (command 'h'):
|
See also
| ps, pstree |