以下是檢視cpu佔用率的乙個指令碼
/export/home/arbsfr/sfr_entreprise/sfre3/cpu_record.sh
and you can run it as below :
sh cpu_record.sh
發現他用的是/usr/ucb/ps 而不是我們通常用的ps(/bin/ps).#!bin/sh
/usr/ucb/ps -auxww | grep '%cpu' | grep -v 'grep'
while [ 1 ]
do /usr/ucb/ps -auxww | grep $1 | grep -v 'cpu_record.sh' | grep -v 'grep'
sleep 10
done
/usr/ucb這個目錄裡面放的是berkley 的命令,屬於歷史遺留命令.both /usr/bin/ps and /usr/ucb/ps are hard link to /usr/lib/isaexec, which analyses the path and execute the binary differently. /usr/ucb/ps is berkley style and /usr/bin/ps is svr4 style. however, they are the same file.
執行指令碼後我們可以檢視cpu的佔用率如下所示:
user pid %cpu %mem sz rss tt s start time command
arbsfr 8331 0.2 0.17315263944 pts/32 s 08:23:35 0:06 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.4 0.17724868040 pts/32 o 08:23:35 0:14 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.4 0.1122304113096 pts/32 o 08:23:35 0:19 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.5 0.1155072145864 pts/32 o 08:23:35 0:27 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.5 0.2167360158152 pts/32 o 08:23:35 0:35 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.2179648170440 pts/32 o 08:23:35 0:42 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.2224704215496 pts/32 o 08:23:35 0:50 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.2269760260552 pts/32 o 08:23:35 0:58 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.3306624297416 pts/32 o 08:23:35 1:06 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.3359872350664 pts/32 o 08:23:35 1:13 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.3404928395872 pts/32 o 08:23:35 1:19 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.3404928395872 pts/32 o 08:23:35 1:26 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.3404928395872 pts/32 s 08:23:35 1:32 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.5 0.3409024399968 pts/32 s 08:23:35 1:39 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.5 0.3409024399968 pts/32 o 08:23:35 1:45 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.5 0.4429760421056 pts/32 o 08:23:35 1:52 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.4429760421064 pts/32 s 08:23:35 2:00 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.4429760421064 pts/32 o 08:23:35 2:07 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.4429760421064 pts/32 o 08:23:35 2:13 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.5 0.4429760421064 pts/32 s 08:23:35 2:19 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
arbsfr 8331 0.6 0.4429760421256 pts/32 o 08:23:35 2:27 /export/home/arbsfr/helen/797/bin/cap.yy cap08 4
檢視CPU佔用率
檢視系統cpu佔用率 在跑一些程式,例如deep learning的時候,總是希望檢視一下cpu gpu 記憶體的使用率 1.cpu 記憶體 使用top命令 top 有乙個更直觀的監測工具,叫htopsu doap t ge tins tall htop s ud oapt get inst all...
CPU測試 檢視cpu佔用率
一 使用命令adb shell top m 10 s cpu t 顯示程序名稱,s 按指定行排序,n 在退出前重新整理幾次,d 重新整理間隔,m 顯示最大數量 如下圖 引數含義 pid progressidentification,應用程式id s 程序的狀態,其中s表示休眠,r表示正在執行,z表示...
Linux下如何檢視高CPU佔用率執行緒
在 linux 下 top 工具可以顯示 cpu 的平均利用率 user,nice,system,idle,iowait,irq,softirq,etc.可以顯示每個 cpu 的利用率。但是無法顯示每個執行緒的 cpu 利用率情況,這時就可能出現這種情況,總的 cpu 利用率中 user 或 sys...