How to capture the output of a top command in a file in linux?

后端 未结 10 1004
梦如初夏
梦如初夏 2020-12-24 06:14

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         


        
10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 06:38

    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.

提交回复
热议问题