Linux top shows which CPU each process is executing on

Source: Internet
Author: User
Tags memory usage safe mode sorts terminates time interval gluster

The current process and other status of the top display system is a dynamic display process that refreshes the current state with user keystrokes. If the command is executed at the foreground, it will monopolize the foreground until the user terminates the program. More precisely, the top command provides real-time state monitoring of the system's processors. It will show the CPU most "sensitive" in the system Task List. This command can be used by the CPU. Memory usage and execution times are used to sort tasks, and many of the commands can be set through interactive commands or in personal custom files.

command to use

Top Use Format

Top [-] [d] [P] [Q] [C] [C] [s] [s] [n]


parameter Description

d Specifies the time interval between refresh of the screen information every two times. Of course, users can use the s interactive command to change it.
P monitors only the state of a process by specifying the monitoring process ID.
Q This option will cause top to be refreshed without any delay. If the calling program has Superuser privileges, top will run at the highest possible priority level.
S Specifies the cumulative mode
s makes the top command run in Safe mode. This removes the potential risk of interaction commands.
I make top do not show any idle or zombie processes.
C Displays the entire command line instead of just displaying the command name

Other practical commands

The following are some of the interaction commands that you can use during the top command execution. From a usage point of view, mastering these commands is more important than mastering the options. These commands are all single letters, and if the S option is used in command-line options, some of these commands may be blocked.

Ctrl+l Erase and rewrite the screen.
H or? Displays the help screen, giving some brief summary instructions.
K Terminates a process. The user is prompted to enter the process PID that needs to be terminated, and what signal needs to be sent to the process. The general termination process can use 15 signals, and if not, use signal 9 to force the end of the process. The default value is signal 15. This command is blocked in safe mode.
I ignore idle and zombie processes. This is a switch command.
Q quit the program.
R to reschedule a process's priority level. The system prompts the user to enter the process PID to be changed and the process priority value that needs to be set. Entering a positive value causes the priority to be lowered, whereas the process can have a higher priority. The default value is 10.
S switch to cumulative mode.
s changes the delay time between two times of refresh. The user will be prompted to enter a new time in the unit S. If there is a decimal number, it is converted to M S. Enter a value of 0 and the system will refresh continuously with the default value of 5 S. It is important to note that if the setting is too small, it is likely to cause a constant refresh, so it is too late to see the display of the situation, and the system load will be greatly increased.
F or F to add or remove items from the current display.
O or O change the order in which items are displayed.
L Toggle Display Average load and start time information.
M toggles the display of memory information.
T toggles the display of process and CPU state information.
C Toggles the display of the command name and the full command line.
M sorts based on the size of the resident memory.
P is sorted according to the percentage size used by the CPU.
T sorts according to time/cumulative time.
W writes the current settings to the ~/.TOPRC file. This is the recommended method for writing the top configuration file.

With common operation:

Top//Every 5 seconds the resource occupancy of all processes in an explicit
Top-d 2//2-second explicit resource occupancy for all processes
TOP-C//Every 5 seconds the resource consumption of the explicit process and display the command line arguments for the process (the default is only the process name)
Top-p 12345-p 6789//every 5 seconds the PID is 12345 and the PID is 6789 of the two process resource occupancy
top-d 2-c-P 123456//2 SEC shows the resource usage of the process with PID 12345, and explicitly the command line arguments that the process starts

Top shows which CPU each process is executing on

After running top, press 1 to see the busy situation on each CPU as well as the iowait.

However, I would like to see exactly which process is executing on which CPU, and which process is causing the iowait to be very high.

Look at man top and finally find a way:

After the top is executed, press F, Press J, and then press the space to exit, so that a column of #c appears and you can see which CPU the current process is executing on.

Press W (uppercase W) to write the top configuration to the configuration file and see the same configuration the next time you open the top.

View the PHP process running on top of that CPU

Ps-eo Pid,args:50,psr|grep worker.php

To see which CPU the process is currently running on, you can perform Ps-eo PID,ARGS,PSR

[Gluster@platform3 local]$$ Ps-eo PID,ARGS,PSR

PID COMMAND PSR

1 init [3] 0

。。。

7546 Ssh-agent-s 3

8253 Sshd:gluster [P 2

8255 sshd:gluster@pt 2

8256-bash 0

8285/home/gluster/lo 1

8334 Ps-eo Pid,args, 1

8403/home/gluster/lo 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.