LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 01-14-2009, 04:48 AM   #1
dourk
LQ Newbie
 
Registered: Jul 2006
Posts: 21

Rep: Reputation: 0
top: order pids by memory instead of CPU usage


Hello

The title says it all: Command top displays the pids (tasks) by order of CPU usage. Could I make it order them by memory usage?

Thank you
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 01-14-2009, 04:53 AM   #2
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
I think it depends on the distro you are using.

type
Code:
$ top
then in top, type '?'
This will tell you how to do it.

It depends on distributions.

Debian uses '<' and '>'
Redhat uses 'o' and 'O'
...
 
Old 01-14-2009, 04:55 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,309

Rep: Reputation: 1032Reputation: 1032Reputation: 1032Reputation: 1032Reputation: 1032Reputation: 1032Reputation: 1032Reputation: 1032
You can sort by any of the fields - see the manpage, or enter a "?" while in top itself.
 
Old 02-22-2010, 09:40 AM   #4
abel.bolanos
LQ Newbie
 
Registered: Feb 2010
Location: Cuba
Distribution: Ubuntu, Debian, CentOS
Posts: 1

Rep: Reputation: 2
Thumbs up Use this

Call top
then inside make Shift+F
now is list by %CPU
then press 'n' for order by memory
 
2 members found this post helpful.
Old 10-17-2013, 06:49 AM   #5
loginagain
LQ Newbie
 
Registered: Oct 2013
Posts: 3

Rep: Reputation: Disabled
These work in interactive mode. How about batch mode under redhat?
 
Old 10-17-2013, 07:02 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by loginagain View Post
These work in interactive mode. How about batch mode under redhat?
You cannot use ordering options from the command line, but you can use a workaround to accomplish this.

- Start top (normal mode),
- set order (To order by memory: O n <enter>),
- write config file (W),
- quit top

A .toprc file is now present in your home directory, which will be read when using batch mode.

Possible downside: This .toprc file is always read when using top.....
 
1 members found this post helpful.
Old 10-17-2013, 07:11 AM   #7
loginagain
LQ Newbie
 
Registered: Oct 2013
Posts: 3

Rep: Reputation: Disabled
Thanks druuna. Indeed having the configuration set as default is not desirable. The workaround would need to have a few extra steps, for example renaming the .toprc file to disable/enable it. A bit heavy but it should work
 
Old 10-17-2013, 07:40 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by loginagain View Post
Thanks druuna. Indeed having the configuration set as default is not desirable. The workaround would need to have a few extra steps, for example renaming the .toprc file to disable/enable it. A bit heavy but it should work
You could create a function to automate this (add to ~/.bashrc or appropriate file):
Code:
function topm () {
  cp /home/<user>/.toprc.mem /home/<usr>/.toprc
  top $@
  rm /home/<user>/.toprc
}
The above assumes the presence of .toprc.mem (config file that orders by memory usage).

You can now run topm or topm -b -d2, using top will still behave as if there where no config file.
 
1 members found this post helpful.
Old 10-17-2013, 09:23 AM   #9
loginagain
LQ Newbie
 
Registered: Oct 2013
Posts: 3

Rep: Reputation: Disabled
Muchas gracias
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
CPU usage from top jr8rdt Linux - Newbie 10 08-17-2011 06:46 AM
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
Top CPU usage explanation penguinco Fedora 3 11-30-2004 01:01 PM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 05:55 AM


All times are GMT -5. The time now is 07:12 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration