Call the top command in the script

Source: Internet
Author: User

The top command in the Linux system is an interactive command, so the script executes when it is stuck and no longer executes the next command.

The solution is: top-n 1.

Command usage explained:

1. Brief introduction
Display the current process and other status of the system;
The Top command provides real-time status monitoring of the system's processor. It displays a list of the most "sensitive" tasks in the system. This command can be used by CPU. Memory usage and execution time sorting tasks , and many of the features of the command can be set through interactive commands or in personal customization files.

2. Usage
2. 1 Using formats
N] [n sets the number of screen refreshes before exiting
The top output is organized into a format suitable for output to a file, and you can use this option to create a process log
Q This option will enable top to run at the highest possible priority level
C Displays the entire command line instead of just displaying the command name
S Specifies the cumulative mode
s so that top does not show any idle or zombie processes.

2.3 Interactive Command Description
Below is a description ofNSort by PID
Shift+p Sort by CPU
Shift+m Sort by memory usage
Shift+t Sort by CPU time
Shift+</shift+> sort by the next left column/Sort by the next column on the right
U Enter user name to display only the process of the specified user
TopShow
H or? Display the help screen and give some brief summary of the commands
K Terminates a process. The user will be prompted for the process PID to be terminated and what signal needs to be sent to the process. The normal termination process can use a 15 signal, and if not, use signal 9 to force end the process. The default value is signal 15. This command is masked in safe mode
I ignore idle and zombie processes. This is a switch-type command.
Q quit the program.
R reschedule the priority level of a process. The user is prompted to enter the process PID that needs to be changed and the process priority value that needs to be set. Entering a positive value lowers the priority and, conversely, it gives the process a higher priority. The default value is 10.
S switch to cumulative mode.
s changes the delay time between two refreshes. The user will be prompted to enter a new time in S. If there are decimals, it is converted into Ms. Enter a value of 0 and the system will continue to refresh, the default value is 5s. It is important to note that if you set too small a time, it is likely to cause a constant refresh, so it is too late to see the display, and the system load will be greatly increased.
D function Ibid.
F or F 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 display memory information.
T toggles the display of process and CPU status information.
The C toggle Displays 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 of CPU usage.
T is sorted by time/accumulated time.
W writes the current settings to the ~/.TOPRC file. It's writtenTop-D 5 Update delay set to 5 seconds (default 3 seconds)
[Email protected] ~]#MySQL only view the process of a valid user named MySQL
[[email protected] ~]# top -p 200,2000 only view processes 200 and 2000
[[email protected] ~]# n 8 before exiting the screen and then refreshing 10 times
[[email protected] ~]# b runs in non-interactive and non-full-screen mode
[[email protected] ~]# b -12000 > Plog run top and record command output, 10 hours, save to Plog file

Call the top command in the script

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.