Capture Unix top command output into a file
Wednesday, November 21st, 2007Firstly, you need to make sure that your top command does not redisplay the output. This is what you do on Linux and Mac OS:
Linux:
$ top -b -n 1
Mac OS X:
$ top -l 1
(Note that the first sample displayed will have an invalid %CPU displayed for each process, as it is calculated using the delta between samples. (from the top manual))
You can use a standart Unix command in order to save the details to a file:
$ top -b -n 1 > my_top_report.txt