Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 05-07-2014, 05:22 AM   #1
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

top -b -n 10 -d 10
Old 05-07-2014, 05:47 AM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
Do you have any particular 5 in mind, or will any do?
If the latter, use tail
top -b -n 1 -d 1|tail -5
Old 05-08-2014, 01:49 AM   #3
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
Registered: Apr 2014
Distribution: Arch
Posts: 39

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

Rep: Reputation: 273Reputation: 273Reputation: 273
for i in {1..10}; do top -b -n 1 | tail +7 | head -6; sleep 10; echo ""; done
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


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
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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:58 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration