LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-27-2006, 07:21 AM   #1
Narayandutt
LQ Newbie
 
Registered: May 2006
Posts: 11

Rep: Reputation: 0
Wants to execute top for only 5 seconds


hi friends,
As you all know when we give top commands it shows us top processes according to cpu usage. but the process is continuosly on untill we abort the top process by pressing 'control+c'. I wants this process
to automatically killed after 5 seconds. and I should come back to bash prompt. can anyone let Me know the script for it

Thanks
 
Old 11-27-2006, 08:29 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Why would you want to display top for 5 seconds then quit? If it's the load average or top processes you want, you should get this info from uptime or the ps command.

And the proper way to exit out of top is the letter q for quit.
 
Old 11-27-2006, 08:55 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You can specify update delay time and number of iterations using the -d and -n options. e.g.
Code:
top -d 5 -n 1
which would delay 5 seconds between iterations, and quit after 1. You could also get a "five second run" also using the opposite:
Code:
top -d 1 -n 5
...which would update once every second and terminate after 5 seconds.

All this is documented in more detail in the manual page. To read the manual page, you use the command:
Code:
man top

Last edited by matthewg42; 11-27-2006 at 08:56 AM. Reason: typos typos typos - sigh.
 
Old 11-28-2006, 04:00 AM   #4
Narayandutt
LQ Newbie
 
Registered: May 2006
Posts: 11

Original Poster
Rep: Reputation: 0
Hi,
I really thank you for giving Me those many replies.
Thanks a lot
 
  


Reply



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
convert total no of seconds in the format hour minutes and seconds suchi_s Programming 15 03-15-2011 11:34 AM
get logged out every 5 seconds Avatar LQ Suggestions & Feedback 4 12-20-2005 10:13 AM
Logged in for 10 seconds or less Yawgmoth7 Linux - Software 1 11-01-2005 07:43 AM
SECONDS per FRAME opensource Linux - General 4 02-01-2004 04:04 AM
strftime - 61 seconds?!?!?!? esnagel Linux - General 2 09-12-2002 07:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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