View Full Version : top command
vancenase
04-19-2004, 12:44 PM
hi all
under linux, when i type 'top' then 'q' within top to quit, my screen still shows the results of the top session after exiting to the command prompt.
but, under OS X (using X11), it does not. typing 'q' in 'top' results in a blank terminal window.
anyway to change that?
thanks.
yellow
04-19-2004, 12:46 PM
Control-C does what you want.
vancenase
04-19-2004, 12:54 PM
that seems to do the same as 'q' (blank terminal). is there an updated 'top' i don't have?
DeltaMac
04-19-2004, 01:04 PM
hmm, which behavior do you want to change? (Linux or X11?)
vancenase
04-19-2004, 01:06 PM
X11. i want top under X11 to behave similar to linux. basically, i'm just trying to see what processes are running and at what CPU %. top under X11 sorts based on PID, and under linux based on CPU % used too.
yellow
04-19-2004, 01:07 PM
Hmm, as far as I can remember this has always done this for top in OS X.
Are you using Terminal.app? iTerm? What shell? I've been using tcsh for many years, hate bash with a passion, and refuse to switch.
Edit: Duh, X11, which you said.
Top "under X11" and top "under OS X" are the same top. But now I see what you mean, when you quit the process, the top info doesn't stay. I don't know why. FYI: the -u flag sorts by CPU usage.
vancenase
04-19-2004, 01:15 PM
ah, many thanks for the sort option ... i'm using TCSH. the info disappearing is a pain though. do you know of another command that may give a similar result?
i work with some buggy scientific apps. sometimes they crash after using them for extended periods of time, so i use top to find the PID (i find it easily because the CPU% jets to ~100%), then use 'kill -KILL $PID' to top the process.
any ideas?
adamgibbs
04-19-2004, 01:24 PM
A simple way to do that is to use ps -auxrcU$USERNAME this will return a list of active processes initiated by your user sorted by processor use. Since that command is nowhere as quick on the fingers as 'top' I'd reccomend aliasing it to something with a few fewer letters.
hayne
04-19-2004, 01:32 PM
i work with some buggy scientific apps. sometimes they crash after using them for extended periods of time, so i use top to find the PID (i find it easily because the CPU% jets to ~100%), then use 'kill -KILL $PID' to top the process.
If there is only one instance of a given program running at any one time, then you could use 'killall' to get rid of your errant processes.
E.g., if the program is called "foo", you would do:
killall foo
vancenase
04-19-2004, 01:35 PM
cool. i made the following alias in my .cshrc (not sure if the sort option is optimal, but it works):
alias dpr 'ps -auxrcU$USERNAME | sort +3 | tail -11 | head -10'
vancenase
04-19-2004, 01:36 PM
If there is only one instance of a given program running at any one time, then you could use 'killall' to get rid of your errant processes.
E.g., if the program is called "foo", you would do:
killall foointeresting, i didn't know that! many thanks!
The reason top does this is that your TERM is set to xterm (or xterm-color), so things which can take over the window (top, vim, etc) will replace the screen with the original contents when you quit.
You can keep it from doing this by temporarily setting TERM to a less-intelligent terminal:
env TERM=vt100 top
should keep the results from top when you quit.
chris_on_hints
04-22-2004, 10:59 AM
FYI: this behaviour started when I went up to 10.3. It happens with every program that 'takes over' the terminal screen (text editors like pine, email like pico etc....)
On 10.2 and earlier the results stayed after exiting the program.
By putting "setenv TERM vt100" into your .tcshrc will sort this one out. BUT, terminal will no longer let you have colour output... so im stuck using "setenv TERM xterm-color".
see hint on macosxhints.com (http://www.macosxhints.com/article.php?story=20031025162727485)
chris_on_hints
04-22-2004, 11:09 AM
STOP THE PRESS!!
I was just looking on the macosxhints link i supplied above - and saw a solution....
"setenv TERM dtterm"
this has colour and keeps your output on the screen after ending top, pine etc.
enjoy!!!
vancenase
04-22-2004, 12:10 PM
excellent! thanks for the dtterm hint!
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.