1, under Linux to obtain the most CPU-intensive 10 processes, you can use the following command combination:
PS Aux|head-1;ps aux|grep-v pid|sort-rn-k +3|head
2, under Linux to get the memory resources up to 10 processes, you can use the following command combination:
PS Aux|head-1;ps aux|grep-v pid|sort-rn-k +4|head
3, command combination resolution (for CPU, men also the same reason):
PS Aux|head-1;ps aux|grep-v pid|sort-rn-k +3|head
This combination of commands is actually the following two lines of command:
PS Aux|head-1ps aux|grep-v pid|sort-rn-k +3|head
You can use the command to check the 10 processes with the most memory
View the process that consumes the highest CPU
PS Aux|head-1;ps aux|grep-v pid|sort-rn-k +3|head or Top (then press m, note that this is uppercase)
View the most memory-intensive processes
PS Aux|head-1;ps aux|grep-v pid|sort-rn-k +4|head or Top (then press p, note that this is uppercase)
This combination of commands is actually the following two lines of command:
PS Aux|head-1ps aux|grep-v pid|sort-rn-k +3|head
The first sentence is primarily to get the title (USER PID%cpu%MEM VSZ RSS TTY STAT START time COMMAND).
The next grep-v PID is to remove the title of the PS aux command, that is, grep does not contain the three-letter combination of the PID line, and then the result is sorted using sort.
Sort-rn-k +3 the-rn R in this command is ordered in reverse order, n is sorted by numeric size, and-K +3 is sorted for the contents of column 3rd, and the first 10 rows of data are obtained by using the Head command. (where | represents a pipeline operation)
Supplemental: Content Interpretation
PID: ID of the process
USER: Process Owner
PR: The priority level of the process, the smaller the higher the priority is executed
Ninice: Value
VIRT: Virtual memory consumed by the process
RES: The physical memory occupied by the process
SHR: Shared memory used by the process
S: The state of the process. s for hibernation, R for running, Z for Zombie, n for the process priority value is negative
%CPU: Process Consuming CPU utilization
%MEM: The percentage of physical memory and total memory used by the process
Time+: The total CPU time that is consumed after the process is started, which is the cumulative value of the CPU usage time.
Command: Process start name
You can use the following command to check the K processes using the most memory
Method 1:
Ps-aux | Sort-k4nr | Head-k
If it is 10 processes, k=10, if it is the highest of three, k=3
Description:in Ps-aux (a refers to all the processes of all--, u refers to the userid--executing the process, the user id,x means to display all programs, not to differentiate by terminal)
The output format of the Ps-aux is as follows:
USER PID%cpu%MEM VSZ RSS TTY STAT START time commandroot 1 0.0 0.0 19352 1308? Ss Jul29 0:00/sbin/initroot 2 0.0 0.0 0 0? S Jul29 0:00 [kthreadd]root 3 0.0 0.0 0 0? S Jul29 0:11 [migration/0]
Sort-k4nr (k represents starting from the first position, the following number 4 is the beginning of the position, the end position if not, then the default to the last; n refers to the numberic sort, according to its numerical order; R refers to the reverse, here refers to the reverse comparison results, the output by default from small to large, Reverse backwards from large to small. )。 In this example, you can see%mem in the 4th position, based on the value of%mem, from the large to the small sort.
Head-k (K refers to the number of rows, which is the result of the first few outputs)
| For the pipe symbol, the result of the query is directed to the following command for next steps.
Method 2:top (then press m, note upper case)
Second, you can use the following command to check the use of the most CPU K process
Method 1:
Ps-aux | Sort-k3nr | Head-k
Method 2:top (then press p, note uppercase)
How to see which processes consume the most CPU memory resources under Linux