LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 05-07-2014, 05:22 AM   #1
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Rep: Reputation: Disabled
top command


Hi everyone,

I want to run Top command in batch mode every 10 seconds for 10 iterations & at the same time I want to limit the number of process shown in the top command output. I'm unable to locate how to do that ,please suggest

I'm using the below command & this is printing all the process running on the system , I want only 5 processes to be displayed in each iteration.pls help

Quote:
top -b -n 10 -d 10
 
Old 05-07-2014, 05:47 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Do you have any particular 5 in mind, or will any do?
If the latter, use tail
Code:
top -b -n 1 -d 1|tail -5
 
Old 05-08-2014, 01:49 AM   #3
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
This will not work as I want to iterate the output 10 times after every 10 seconds , using tail will output once one.

And I want the top 5 processes hence using tail command is not appropriate.
 
Old 05-08-2014, 01:52 AM   #4
bstaletic
Member
 
Registered: Apr 2014
Distribution: Arch
Posts: 39

Rep: Reputation: Disabled
Try this:
Code:
top -b -n 10 -d 10 | tail -5
 
Old 05-08-2014, 02:06 AM   #5
kooru
Senior Member
 
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 275Reputation: 275Reputation: 275
Code:
for i in {1..10}; do top -b -n 1 | tail +7 | head -6; sleep 10; echo ""; done
Code:
for i in {1..10}; do top -b -n 1 | head -n 12; sleep 10; echo ""; done
tested on slackware

Last edited by kooru; 05-08-2014 at 02:30 AM. Reason: added alternative
 
  


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
top command Volcano Linux - General 1 02-09-2012 07:13 AM
LXer: Can You Top This? 15 Practical Linux Top Command Examples LXer Syndicated Linux News 0 01-09-2010 09:42 PM
Finding the top CPU-using processes? "top" command does not help... catalytical Linux - Server 1 04-06-2009 04:50 PM
top command Volcano Programming 18 10-15-2008 10:02 PM
Top Command swamprat Linux - Software 3 09-23-2007 02:08 AM

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

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