top sort by high cpu util processes

Fred Roller froller at tnclimited.com
Thu Aug 27 02:42:05 UTC 2009


On Wed, 2009-08-26 at 21:52 -0400, Fred Roller wrote:
> On Wed, 2009-08-26 at 18:44 -0700, Noah Garrett Wallach wrote:
> > Hi there,
> > 
> > Is there any way to get 'top' to sort by high cpu util processes
> > 
> > top -o cpu is not working for me.
> > 
> > ~$ top -o cpu
> >          top: unknown argument 'o'
> > usage:  top -hv | -bcisSH -d delay -n iterations [-u user | -U user] -p 
> > pid [,pid ...]
> > 
> > 
> > CHeers,
> > 
> > Noah
> > 
> 
> Have you tried typing "?" (a question mark) after you start top.  It
> should give you the options necessary to manipulate the program.

continuing...

Start top with no options:

	froller at metis:~$ top

then type "[shift]+o" (capital letter *oh*) which will give you this
screen:

<screen>

Current Sort Field:  K  for window 1:Def
Select sort field via field letter, type any other key to return 

  a: PID        = Process Id                                            
  b: PPID       = Parent Process Pid                                    
  c: RUSER      = Real user name                                        
  d: UID        = User Id                                               
  e: USER       = User Name
  f: GROUP      = Group Name
  g: TTY        = Controlling Tty
  h: PR         = Priority
  i: NI         = Nice value
  j: P          = Last used cpu (SMP)
* K: %CPU       = CPU usage
  l: TIME       = CPU Time
  m: TIME+      = CPU Time, hundredths
  n: %MEM       = Memory usage (RES)
  o: VIRT       = Virtual Image (kb)
  p: SWAP       = Swapped size (kb)
  q: RES        = Resident size (kb)
  r: CODE       = Code size (kb)
  s: DATA       = Data+Stack size (kb)
  t: SHR        = Shared Mem size (kb)
  u: nFLT       = Page Fault count
  v: nDRT       = Dirty Pages count
  w: S          = Process Status
  x: COMMAND    = Command name/line
  y: WCHAN      = Sleeping in Function
  z: Flags      = Task Flags <sched.h>

Note1:
  If a selected sort field can't be
  shown due to screen width or your
  field order, the '<' and '>' keys
  will be unavailable until a field
  within viewable range is chosen.

Note2:
  Field sorting uses internal values,
  not those in column display.  Thus,
  the TTY & WCHAN fields will violate
  strict ASCII collating sequence.
  (shame on you if WCHAN is chosen)
                                                                          
</screen>

in this screen type "[shift]+k" (capital letter *kay*) and then just hit
return.  Top is now sorting by cpu percentage used (note the letter
above with the Astrix [*] next to it).  

Just for fun you can type "i" (lower case *eye*) and top only processes
>=1% will list so you don't need to stare at the 0% list.  Hope this
helps.
-- 
Fred R.
www.fwrgallery.com

"Life is like Linux - simple; if you are fighting it, you are doing
something wrong."






More information about the ubuntu-users mailing list