Capture top command to file

时间:2015-10-30 22:21:56

标签: linux ubuntu centos server

I want to capture the output of top to a file but there is a problem, the output is always the same. For example, the code below grabs the %CPU returned by the top command. The problem is that everytime I execute this code it shows the same %CPU usage, why?

top -n 1 | awk '/^%Cpu\(s\)/ {print $2}'

0 个答案:

没有答案