Tuesday, December 16, 2008
By default, top is invoked using interactive mode in which top runs indefinitely and accepts keypress to redefine how top works.
But, in case one need to post-process the top's output and this is hardly achieved using this interactive mode. For this we need to use top's batch mode.
from man pages of top:
-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.
So this is how we can redirect top output to a file.
$ top -b -n 1 > top.out.$(date +%s)
- Linux htop command - an interactive process viewer for Linux
© Jadu Saikia www.UNIXCL.com