LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   top-execute and exit (https://www.linuxquestions.org/questions/linux-newbie-8/top-execute-and-exit-780353/)

chamila1986 01-06-2010 02:37 PM

top-execute and exit
 
Is there a way to execute top command once and exit...i.e. stop refreshing window and continue console without pressing 'q' or 'ctrl+c'...

EricTRA 01-06-2010 02:41 PM

Hi,

Have a look at the man page of top:
Code:

man top
There is an option -n to state number of iterations. So if you type:
Code:

top -n 1
it will run once and exit.

Kind regards,

Eric

colucix 01-06-2010 03:36 PM

In addition you may consider the -b (batch) option in conjunction with -n. This will produce an output formatted for interacting with other programs and will give the complete list of processes (not only those ones you can see in the limited amount of rows in the current terminal):
Code:

top -b -n 1
Cheers!


PS - Hi, Eric! :)

EricTRA 01-07-2010 01:47 AM

Quote:

Originally Posted by colucix (Post 3816720)
In addition you may consider the -b (batch) option in conjunction with -n. This will produce an output formatted for interacting with other programs and will give the complete list of processes (not only those ones you can see in the limited amount of rows in the current terminal):
Code:

top -b -n 1
Cheers!


PS - Hi, Eric! :)

Hi colucix,

What's up? How are you? And most important: Happy New Year!

Kind regards,

Eric


All times are GMT -5. The time now is 01:13 AM.