LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Capturing output of top command (https://www.linuxquestions.org/questions/linux-enterprise-47/capturing-output-of-top-command-4175542462/)

RHCE_ran 05-13-2015 05:56 AM

Capturing output of top command
 
We have RHEL 5.11 in our production environment. I had some confirmation and some observation with capturing output of top command.

1) To capture top output,

top –n 3 –b > top.lst

should be fine?

2) I had observation that top command output can be very long which may not be evident if we give top at prompt and do Ctrl+C. This was an observation that the top command at prompt could be displaying only 1 screen at a time whereas the complete output of top command can be 3 page scrolls.

I hope, I have been able to explain my query and observation with regard to capturing output of top command.

Requesting a reply to my query.

Regards

syg00 05-13-2015 05:59 AM

Yes.
Yes.

Sefyir 05-15-2015 08:58 PM

The command will do three iternations of the top command and be formatted for being send to a text file.

Code:

      -b  :Batch-mode operation
            Starts top in 'Batch' mode, which could be useful for sending
            output  from  top  to  other  programs or to a file.  In this
            mode, top will not accept input and runs until the iterations
            limit  you've  set with the '-n' command-line option or until
            killed.

Code:

      -n  :Number-of-iterations limit as:  -n number
            Specifies the maximum number of iterations,  or  frames,  top
            should produce before ending.

If that is what you want, then it is fine. It will be long because it is all output three times. If you want just one iteration, perhaps change -n to 1?


All times are GMT -5. The time now is 01:10 PM.