LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-24-2011, 09:54 AM   #1
Linux_Newbie90
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
Sorting Process Lists


I am trying to show only the processes that use more than 10% of the cpu. I have managed to get it to show the processes in use using:

ps -eo pcpu,cpu,nice,state,cputime,args.

Then I am unsure how to sort this information so it only shows over 10%?

Any help would be much appreciated.
 
Old 04-24-2011, 10:13 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Code:
top -d1 -n1 -b | awk 'BEGIN{d=0};{if(/PID USER/)d=1;if(d==1 && $9>10)print}'
 
Old 04-24-2011, 12:27 PM   #3
Linux_Newbie90
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Original Poster
Rep: Reputation: 0
This doesn't seem to work. Is there not a way you can do it using ps command ?

Thanks for the reply.
 
Old 04-24-2011, 01:10 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Expanding on what you already have:
Code:
ps -eo pcpu,cpu,nice,state,cputime,args --sort pcpu | awk '$1 >= 10 { print }'
Hope this helps

EDIT: Just to make sure - The --sort pcpu part isn't needed, it is there to show how to use the sort option the ps command has.

Last edited by druuna; 04-24-2011 at 01:23 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Unique Sorting Of Lists And Lists Of Lists With Perl For Linux Or Unix LXer Syndicated Linux News 0 09-05-2008 01:50 PM
LXer: Sorting Perl Lists And Removing Duplicates On Linux Or Unix LXer Syndicated Linux News 0 09-04-2008 05:20 AM
`top` Irregularities - cpu count, percentage, process lists ColinAnderson Linux - Software 4 05-09-2007 06:41 PM
Sorting process with ps sebasguay Linux - General 2 02-15-2007 01:43 PM
sorting in linking lists showri Programming 2 09-14-2006 05:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration