LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   top command (https://www.linuxquestions.org/questions/linux-newbie-8/top-command-4175504185/)

vicky007aggrwal 05-07-2014 05:22 AM

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

chrism01 05-07-2014 05:47 AM

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

vicky007aggrwal 05-08-2014 01:49 AM

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.

bstaletic 05-08-2014 01:52 AM

Try this:
Code:

top -b -n 10 -d 10 | tail -5

kooru 05-08-2014 02:06 AM

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


All times are GMT -5. The time now is 04:07 PM.