How do I capture the output of “top” to a file?

This will run top once write the output to a file and exit. The command top can also be run so that it will give multiple reports.

top -b -n1 > /tmp/top.txt

To run top 5 times and wait 5 seconds between each output the command would be:

top -b -n5 -d5 > /tmp/top.txt

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.