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 questionI 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.
精彩评论