linux top命令linux
1. 概述(照抄man):緩存
The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by linux kernel. The types of system summary information shown and types, order and size of information displayed for tasks are all user configurable and that configuration can be made persistant across restart.ide
2. 參數:spa
-d:列表內容更新時間,後接秒數: top -d 2 (每2s刷新一次列表)rest
-b:以批次方式執行,後接-n 加數字,表示執行幾回,並能夠將結果輸出到文件:top -b -n2 > /path/x.txt (執行top2次並將結果輸出到/path/x.txt)orm
-p:制定某個PID進行觀測:top -p 13100 (查看PID爲13100的進程的狀況)進程
在啓動top後:內存
輸入k:it
top - 12:31:33 up 20:19, 4 users, load average: 0.17, 0.32, 0.32
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.4%us, 0.6%sy, 2.8%ni, 96.1%id, 0.0%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 3637960k total, 2522020k used, 1115940k free, 166476k buffers
Swap: 3775236k total, 0k used, 3775236k free, 1349512k cached
PID to kill: 13100
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13100 meroc 21 1 1680m 196m 40m S 14 5.5 16:49.79 chromium-browseio
能夠給指定PID的進程一個訊號。
輸入r:
top - 12:32:40 up 20:20, 4 users, load average: 0.20, 0.30, 0.31
Mem: 3637960k total, 2526824k used, 1111136k free, 166568k buffers
Swap: 3775236k total, 0k used, 3775236k free, 1349444k cached
PID to renice: 13100
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13100 meroc 21 1 1680m 196m 40m S 13 5.5 16:58.29 chromium-browse
能夠從新指定進程的NI值(即nice:優先級):
top - 12:32:40 up 20:20, 4 users, load average: 0.20, 0.30, 0.31
Mem: 3637960k total, 2526824k used, 1111136k free, 166568k buffers
Swap: 3775236k total, 0k used, 3775236k free, 1349444k cached
Renice PID 13100 to value: 2
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13100 meroc 21 1 1680m 196m 40m S 13 5.5 16:58.29 chromium-browse
top - 12:36:03 up 20:24, 4 users, load average: 0.23, 0.34, 0.33
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.4%us, 1.1%sy, 2.7%ni, 93.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 3637960k total, 2535472k used, 1102488k free, 166824k buffers
Swap: 3775236k total, 0k used, 3775236k free, 1354968k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13100 meroc 22 2 1680m 196m 40m S 13 5.5 17:24.07 chromium-browse
3.列表屬性:
top - 12:36:03 up 20:24, 4 users, load average: 0.23, 0.34, 0.33
--當前時間,系統運行時間,連接用戶數,系統負載(3個數值分別爲:1,5,15分鐘到如今的平均值);其實這行能夠用uptime命令顯示
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
--進程總數,運行進程數,睡眠進程數,中止進程數,僵死進程數
Cpu(s): 2.4%us, 1.1%sy, 2.7%ni, 93.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
--用戶CPU佔用百分比,系統CPU佔用百分比,用戶進程空間中改變了進程優先級的進程所佔百分比,空閒CPU百分比,等待輸入輸出的CPU所佔百分比
Mem: 3637960k total, 2535472k used, 1102488k free, 166824k buffers
--內存總空間,內存已用空間,內存剩餘空間,做爲內核緩存的內存大小
Swap: 3775236k total, 0k used, 3775236k free, 1354968k cached
--交換區總量,交換區使用量,交換區剩餘大小,緩衝交換區總量。
PID:Process ID
USER:process全部者的ID
PR:priority,優先級,越小越先被執行
NI:nice,優先級相關,也是越小越先被執行
%CPU:CPU使用率
%MEM:內存使用率
TIME+:CPU使用時間累加