Print processes, sorted by usage of CPU
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
I need to print the 10 processes that are using the most CPU. Also I need to print their ID, and the command they were started with.
What I've found is that the command ps -ax -u
prints all the processes and their %CPU usage. The command ps -ax -u --sort pcpu
prints all the processes sorted by the %CPU usage, from the least to the most, but I need to print only 10 processes from the most to the least. I have to use something like sort -r
to make a reverse sorting, but the command ps -ax -u --sort -r pcpu
produces an error.
So, how can I make a reverse sorting and print only 10 of the processes?
linux process sort cpu-usage
add a comment |Â
up vote
5
down vote
favorite
I need to print the 10 processes that are using the most CPU. Also I need to print their ID, and the command they were started with.
What I've found is that the command ps -ax -u
prints all the processes and their %CPU usage. The command ps -ax -u --sort pcpu
prints all the processes sorted by the %CPU usage, from the least to the most, but I need to print only 10 processes from the most to the least. I have to use something like sort -r
to make a reverse sorting, but the command ps -ax -u --sort -r pcpu
produces an error.
So, how can I make a reverse sorting and print only 10 of the processes?
linux process sort cpu-usage
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I need to print the 10 processes that are using the most CPU. Also I need to print their ID, and the command they were started with.
What I've found is that the command ps -ax -u
prints all the processes and their %CPU usage. The command ps -ax -u --sort pcpu
prints all the processes sorted by the %CPU usage, from the least to the most, but I need to print only 10 processes from the most to the least. I have to use something like sort -r
to make a reverse sorting, but the command ps -ax -u --sort -r pcpu
produces an error.
So, how can I make a reverse sorting and print only 10 of the processes?
linux process sort cpu-usage
I need to print the 10 processes that are using the most CPU. Also I need to print their ID, and the command they were started with.
What I've found is that the command ps -ax -u
prints all the processes and their %CPU usage. The command ps -ax -u --sort pcpu
prints all the processes sorted by the %CPU usage, from the least to the most, but I need to print only 10 processes from the most to the least. I have to use something like sort -r
to make a reverse sorting, but the command ps -ax -u --sort -r pcpu
produces an error.
So, how can I make a reverse sorting and print only 10 of the processes?
linux process sort cpu-usage
linux process sort cpu-usage
edited Oct 3 '17 at 13:51
psmears
43528
43528
asked Oct 3 '17 at 9:43
ÃÂøúþûðù ÃÂÃÂÃÂñð
284
284
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
11
down vote
accepted
to print 10 processes, that use the most CPU
ps -aux --sort -pcpu | head
Sorting syntax is
[+|-]key[,[+|-]key[,...]]
.
The "+
" is
optional since default direction is increasing numerical or
lexicographic order. Identical tok
. For example:ps jax --sort=uid,-ppid,+pid
head
- will print the first/top 10 lines of file(s) or standard input (by default)
1
And, for example, if I need not 10, but 15 lines, I will need to writehead -n 15
?
â ÃÂøúþûðù ÃÂÃÂÃÂñð
Oct 3 '17 at 10:04
1
@ÃÂøúþûðùÃÂÃÂÃÂñð, that's right
â RomanPerekhrest
Oct 3 '17 at 10:04
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
11
down vote
accepted
to print 10 processes, that use the most CPU
ps -aux --sort -pcpu | head
Sorting syntax is
[+|-]key[,[+|-]key[,...]]
.
The "+
" is
optional since default direction is increasing numerical or
lexicographic order. Identical tok
. For example:ps jax --sort=uid,-ppid,+pid
head
- will print the first/top 10 lines of file(s) or standard input (by default)
1
And, for example, if I need not 10, but 15 lines, I will need to writehead -n 15
?
â ÃÂøúþûðù ÃÂÃÂÃÂñð
Oct 3 '17 at 10:04
1
@ÃÂøúþûðùÃÂÃÂÃÂñð, that's right
â RomanPerekhrest
Oct 3 '17 at 10:04
add a comment |Â
up vote
11
down vote
accepted
to print 10 processes, that use the most CPU
ps -aux --sort -pcpu | head
Sorting syntax is
[+|-]key[,[+|-]key[,...]]
.
The "+
" is
optional since default direction is increasing numerical or
lexicographic order. Identical tok
. For example:ps jax --sort=uid,-ppid,+pid
head
- will print the first/top 10 lines of file(s) or standard input (by default)
1
And, for example, if I need not 10, but 15 lines, I will need to writehead -n 15
?
â ÃÂøúþûðù ÃÂÃÂÃÂñð
Oct 3 '17 at 10:04
1
@ÃÂøúþûðùÃÂÃÂÃÂñð, that's right
â RomanPerekhrest
Oct 3 '17 at 10:04
add a comment |Â
up vote
11
down vote
accepted
up vote
11
down vote
accepted
to print 10 processes, that use the most CPU
ps -aux --sort -pcpu | head
Sorting syntax is
[+|-]key[,[+|-]key[,...]]
.
The "+
" is
optional since default direction is increasing numerical or
lexicographic order. Identical tok
. For example:ps jax --sort=uid,-ppid,+pid
head
- will print the first/top 10 lines of file(s) or standard input (by default)
to print 10 processes, that use the most CPU
ps -aux --sort -pcpu | head
Sorting syntax is
[+|-]key[,[+|-]key[,...]]
.
The "+
" is
optional since default direction is increasing numerical or
lexicographic order. Identical tok
. For example:ps jax --sort=uid,-ppid,+pid
head
- will print the first/top 10 lines of file(s) or standard input (by default)
edited Oct 3 '17 at 10:05
answered Oct 3 '17 at 9:51
RomanPerekhrest
22.5k12145
22.5k12145
1
And, for example, if I need not 10, but 15 lines, I will need to writehead -n 15
?
â ÃÂøúþûðù ÃÂÃÂÃÂñð
Oct 3 '17 at 10:04
1
@ÃÂøúþûðùÃÂÃÂÃÂñð, that's right
â RomanPerekhrest
Oct 3 '17 at 10:04
add a comment |Â
1
And, for example, if I need not 10, but 15 lines, I will need to writehead -n 15
?
â ÃÂøúþûðù ÃÂÃÂÃÂñð
Oct 3 '17 at 10:04
1
@ÃÂøúþûðùÃÂÃÂÃÂñð, that's right
â RomanPerekhrest
Oct 3 '17 at 10:04
1
1
And, for example, if I need not 10, but 15 lines, I will need to write
head -n 15
?â ÃÂøúþûðù ÃÂÃÂÃÂñð
Oct 3 '17 at 10:04
And, for example, if I need not 10, but 15 lines, I will need to write
head -n 15
?â ÃÂøúþûðù ÃÂÃÂÃÂñð
Oct 3 '17 at 10:04
1
1
@ÃÂøúþûðùÃÂÃÂÃÂñð, that's right
â RomanPerekhrest
Oct 3 '17 at 10:04
@ÃÂøúþûðùÃÂÃÂÃÂñð, that's right
â RomanPerekhrest
Oct 3 '17 at 10:04
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f395796%2fprint-processes-sorted-by-usage-of-cpu%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password