开发者

How to fetch cpu utilization of a particular process in linux [closed]

开发者 https://www.devze.com 2022-12-21 19:07 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Closed 7 years ago.

开发者_如何学JAVA Improve this question

I have used following command to fetch the CPU utilization of a process. It is giving result, but it is not coming out. I have used following command.

top | grep <processname>

I just want to put this in a loop and I will insert sleep in the code so that I can fetch the value in regular intervals


Use top's batch mode, eg.

top -b -n1 | grep processname


You can do:

while [ 1 ]; do top -n 1 | grep something; sleep 1; done

Use the -n option of top:

-n
    Number of iterations. Update the display this number of times and then exit. 
0

精彩评论

暂无评论...
验证码 换一张
取 消