[root@CENTOS7 ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@CENTOS7 ~]#
With the top
command, you can check detailed information such as CPU and memory usage in a list for each process.
By default, the top
command displays the currently running processes in descending order of CPU usage. The display updates in real time and exits when you enter q
.
top command format
top [option]
Main options for the top command
option | Contents |
---|---|
-d interval | Update interval "ss.Specify with "tt seconds" |
-n times | Specify the number of times to repeat the display |
-b | Batch mode. Do not accept key operations, "-The number of times specified by "n" or "CTRL"+Continues execution until killed by "C" etc. Useful when saving the result of top to a file etc. |
-s | Operates in secure mode (does not accept "d" etc. during startup) |
-U user -u user |
Specify the user to monitor by name or ID |
-p process ID | Specify the process ID to monitor. "-p number-p number "or"-p number,You can specify more than one like "number" (blanks can be omitted) |
-c | Switch the COMMAND column (far right) to display the program name or the command line (switch with "c" after startup) |
-i | Switch whether to display idle processes that are not executing anything (switch with "i" after startup) |
-S | Cumulative time mode (switch with "S" after startup) |
-o item | Specify the item used to sort the output (default is CPU usage). The item name that can be specified is "top"-Confirm with "O" For example, if you want to display in descending order of used memory (physical memory occupancy), "top"-o %MEM " |
-w Number of digits | Output width |
You can use the following interactive commands while executing the top
command.
command | Details |
---|---|
Enter、Space | Immediately update the display with the latest information. |
h | Displays the help screen for interactive commands. |
h、? | Displays the help screen for windows and field groups. |
k | Kill the process. You will be prompted for the process ID and the signal to send to the process. |
n | Change the displayed process number. You will be prompted to enter the number. |
u | Sort the list by user. |
M | Sort the list by memory usage. |
P | Sort the list by CPU usage. |
q | Exit the utility and return to the shell prompt. |
The following is displayed with the top
command.
Output result of top command
top - 16:29:43 up 21:14, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 97 total, 1 running, 96 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1014820 total, 401940 free, 187588 used, 425292 buff/cache
KiB Swap: 1679356 total, 1679356 free, 0 used. 676612 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 128040 6712 4176 S 0.0 0.7 0:03.53 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
5 root 20 0 0 0 0 S 0.0 0.0 0:00.19 kworker/u2:0
6 root 20 0 0 0 0 S 0.0 0.0 0:00.91 ksoftirqd/0
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:00.90 rcu_sched
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-dra+
11 root rt 0 0 0 0 S 0.0 0.0 0:00.95 watchdog/0
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
15 root 20 0 0 0 0 S 0.0 0.0 0:00.03 khungtaskd
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
"Current time", "Operating time", "Number of logged-in users", and "Load average" are displayed on the first line.
Display contents on the first line
top - 16:29:43 up 21:14, 1 user, load average: 0.00, 0.01, 0.05
item | Contents |
---|---|
16:29:43 | Current time (16:29:43) |
up 21:14 | Operating time (21 hours 14 minutes) |
1 user | Number of logged-in users (1 user is logged in) |
load average: 0.00, 0.01, 0.05 | Road average for the last 1, 5 or 15 minutes |
The second line shows the status of the task.
Display contents on the second line
Tasks: 97 total, 1 running, 96 sleeping, 0 stopped, 0 zombie
item | Contents |
---|---|
total | Total number of tasks |
running | Number of running tasks |
sleeping | Number of waiting tasks |
stopped | Number of stopped tasks |
zombie | Number of zombie tasks |
The third line shows the CPU status.
Display contents on the third line
%Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
item | Contents |
---|---|
us | Percentage of user process usage time |
sy | Percentage of system process usage time |
ni | Percentage of usage time of the user process whose execution priority has been changed |
id | Percentage of idle time |
wa | I/Percentage of time waiting for the end of O |
hi | Percentage of usage time for hardware interrupt requests |
si | Percentage of usage time for software interrupt requests |
st | Percentage of time waited for calculations by other virtual CPUs when using OS virtualization |
The 4th line shows the memory status.
Display contents on the 4th line
KiB Mem : 1014820 total, 401940 free, 187588 used, 425292 buff/cache
item | Contents |
---|---|
total | Total memory capacity |
free | Unused memory capacity |
used | Memory capacity in use |
buff/cache | Buffer cache/Memory capacity allocated as page cache |
The fifth line shows the status of the swap area.
Display contents on the 5th line
KiB Swap: 1679356 total, 1679356 free, 0 used. 676612 avail Mem
item | Contents |
---|---|
total | Total swap space capacity |
free | Unused swap space capacity |
used | Amount of swap space in use |
avail Mem | Memory capacity that new apps can use without swapping |
From the 7th line onward, the status of each running process is displayed.
Display contents after the 7th line
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 128040 6712 4176 S 0.0 0.7 0:03.53 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
5 root 20 0 0 0 0 S 0.0 0.0 0:00.19 kworker/u2:0
6 root 20 0 0 0 0 S 0.0 0.0 0:00.91 ksoftirqd/0
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:00.90 rcu_sched
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-dra+
11 root rt 0 0 0 0 S 0.0 0.0 0:00.95 watchdog/0
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
15 root 20 0 0 0 0 S 0.0 0.0 0:00.03 khungtaskd
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
item | Contents |
---|---|
PID | Process ID |
USER | Process execution user |
PR | Process static priority (lower numbers have higher priority) |
NI | Relative process priority (based on 0)-20 (high priority) to 19 (low priority)) |
VIRT | Process virtual memory size(Memory capacity plus swapped out memory usage) |
RES | Memory capacity used by the process(Physical memory capacity) |
SHR | Shared memory capacity used by the process |
S | Process state D: Interrupt not possible (sleep) R: Running S: Sleep state T: Stopped (stopped by job control signal) t: Stopped (stopped by the debugger during tracing) Z: Zombie state |
%CPU | CPU usage |
%MEM | Physical memory usage |
TIME+ | Process CPU usage time |
COMMAND | Command name currently being executed |
that's all
Recommended Posts