2010-03-04 91 views
2

我使用以下命令來獲取進程的CPU利用率。它給結果,但它不出來。我使用了以下命令。如何在Linux中獲取特定進程的CPU利用率

top | grep <processname> 

我只想把這個在一個循環中,我將在代碼中插入的睡眠,這樣我可以取回在定期

+0

@mjv - 'Ataboy!' – 2010-03-05 02:40:42

回答

1

你可以這樣做值:

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

使用頂部的-n選項:

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

使用top的批處理模式,

top -b -n1 | grep processname