今天服務器負載突然很高,一下亂了陣腳,以前能用的top,ps,發現我頓時就亂了,然後就google了下,終於眼睛發光 看到了可以用的
取進程ID
1 |
ps aux|grep "^www " |awk '{print $3" " $2}' |sort|tail -n 1|awk '{print $2}' |
2 |
#或 |
3 |
ps auxw --sort=%cpu|awk '{print $3" "$2}' |tail -n 1|awk '{print $2}' |
你懂的:)
跟蹤該進程的動作
1 |
|
功能:查找出佔用CPU最多的前5個進程
ps aux | sort -k3nr | head -n 5
注:結果的第三列爲CPU佔用率
或者也可以用top 然後大寫P