In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Transferred from: https://www.cnblogs.com/sparkbj/p/6148817.html
To get the 10 processes that consume the most CPU resources under linux, you can use the following command combination:
Ps aux | head-1 + PS aux | grep-v PID | sort-rn-k + 3 | head
To get the 10 processes that consume the most memory resources under linux, you can use the following command combination:
Ps aux | head-1 + PS aux | grep-v PID | sort-rn-k + 4 | head
Command combination parsing (the same is true of MEN for CPU):
Ps aux | head-1 + PS aux | grep-v PID | sort-rn-k + 3 | head
This command combination is actually the following two commands:
Ps aux | head-1
Ps aux | grep-v PID | sort-rn-k + 3 | head
You can use the command to find the 10 processes that use the most memory
View the processes that take up the highest cpu
Ps aux | head-1 + PS aux | grep-v PID | sort-rn-k + 3 | head
Or top (then press M, notice that this is uppercase)
View the processes with the highest memory footprint
Ps aux | head-1 + PS aux | grep-v PID | sort-rn-k + 4 | head
Or top (then press P, notice that this is uppercase)
This command combination is actually the following two commands:
Ps aux | head-1
Ps aux | grep-v PID | sort-rn-k + 3 | head
The first sentence is mainly to get the title (USER PID% CPU% MEM VSZ RSS TTY STAT START TIME COMMAND).
The next grep-v PID removes the title from the ps aux command, that is, the grep does not contain the three-letter combination of lines, and sorts the results using sort.
Sort-rn-k + 3 the r of-rn in this command is the reverse order of the results, n is sorted by numeric size, and-k + 3 is sorted for the contents of the third column, and then use the head command to get the first 10 rows of data by default. (the | indicates the pipeline operation)
Supplement: content explanation
PID: the ID of the process
USER: process owner
PR: the priority of the process. The smaller the priority is, the more priority it is to execute.
NInice: valu
VIRT: virtual memory consumed by the process
RES: physical memory consumed by the process
SHR: shared memory used by the process
S: status of the process. S indicates hibernation, R indicates running, Z indicates dead state, and N indicates that the priority value of the process is negative
% CPU: CPU usage occupied by the process
% MEM: percentage of physical memory and total memory used by the process
TIME+: the total CPU time taken after the process was started, that is, the cumulative value of the CPU usage time occupied.
COMMAND: name of the process startup command
You can use the following command to find out the K processes that use the most memory
Method 1:
Ps-aux | sort-k4nr | head-K
If it's 10 processes, Knights 10, if it's the highest three, Knights 3.
Description: in ps-aux (a refers to all processes of all--, u refers to the user of userid-- executing this process, id,x refers to all programs, not distinguished by terminal)
The output format of ps-aux is as follows:
USER PID% CPU% MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 19352 1308? Ss Jul29 0:00 / sbin/initroot 2 0.0 0.0 00? S Jul29 0:00 [kthreadd] root 3 0.0 0.0 00? S Jul29 0:11 [migration/0]
In sort-k4nr (k represents the starting position, followed by the number 4 is its starting position, if not, the end position defaults to the last; n refers to numberic sort, sorted according to its numerical value; r refers to reverse, here it refers to the reverse comparison result, the output defaults from small to large, and reverse from big to small. ). In this example, you can see that% MEM is in the fourth position, sorted from largest to smallest according to the value of% MEM.
Head-K (K refers to the number of lines, that is, outputs the results of the first few digits)
| as a pipe symbol, import the query result to the following command for the next step.
Method 2:top (then press M, note uppercase)
2. You can use the following command to find out the K processes that use CPU most
Method 1:
Ps-aux | sort-k3nr | head-K
Method 2:top (then press P, note uppercase
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.