LinuxQuestions.org
Help answer threads with 0 replies.
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-06-2010, 03:37 PM   #1
chamila1986
Member
 
Registered: Oct 2009
Posts: 31

Rep: Reputation: 15
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'...
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 01-06-2010, 03:41 PM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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
 
1 members found this post helpful.
Old 01-06-2010, 04:36 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
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!
 
2 members found this post helpful.
Old 01-07-2010, 02:47 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by colucix View Post
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
 
1 members found this post helpful.
  


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
Help? how to execute the /etc/profile without having the user exit then logon? icecoolcorey Programming 3 06-12-2008 10:48 AM
Assembly, "bash: ./exit: cannot execute binary file" User Name. Programming 4 08-07-2007 10:09 AM
In perl is there a way when i call exit function to execute a subroutine alix123 Programming 3 06-01-2007 06:38 AM
Wants to execute top for only 5 seconds Narayandutt Linux - Software 3 11-28-2006 05:00 AM
SSH: execute one command then exit kleptophobiac Linux - Software 10 01-30-2004 09:21 PM

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

All times are GMT -5. The time now is 04:26 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