I want to write the output of a specific \'top\' command to a file. I did some googling and find out that it can be done by using the following command.
top
From the top command, we can see all the processes with their PID (Process ID). To print top output for only one process, use the following command:
$ top –p PID
To save top command of any process to a file, use the following command:
top -p $PROCESS_ID -b > top.log
where > redirects standard output to a file.