Linux系統上的進程查看及管理工具:
pstree, ps, pidof, pgrep, top, htop, glances, pmap, vmstat, dstat,kill,job,bg,fg, nohup, nice, renice, killall,…
Centos 5: SysV init
Centos 6: upstart
Centos 7: systemd
/sbin/init,
pstree命令:
pstree – display a tree of processes
ps命令:
/proc/:內核中的狀態信息;
內核參數:
可設置器值從而調整內核運行特性的參數;/proc/sys/
/proc/#:
#:PID
ps – report a snapshot of the current processes
ps [options]:
選項有三種風格:
1 UNIX options, which may be grouped and must be preceded by a dash.
2 BSD options, options, which may be grouped and must not be with a dash.
3 GNU long options, which are preceded by two dashes.
啟動進程的方式:
系統啟動過程中自動啟動:與終端無關的進程;
用戶通過終端啟動;與終端相關的進程;
選項:
a: 所有與終端相關的進程;
x:所有與終端無關的進程
u:以用戶為中心組織進程狀態信息顯示;
常用用組合之一:aux
VSZ: 虛擬內存集;
RSS: Resldent Size , 常駐內存集;
STAT:
R : running
S: interruptable sleeping
D: uninterruptable sleeping
T: Stopped
Z: zomble
+: 前臺進程
l :多謝程進程
<: 高優先級進程
s :session leader
-e: 顯示所有進程
-f: 顯示完整格式的進程信息
常用組合之二: -ef
-F: 顯示完整格式的的進程信息;
C:cpu utilization
PSR : 運行于那顆CPU之上
-H :以層級結構顯示進程的相關信息;
常用組合之三: -eFH
常用組合之四:
o field1 , field2, …: 自定義要顯示的字段列表,以逗號分隔;
o 帶參數 要寫后面
-eo : 常用的field : pid , ni, pri, psr, pcpu, stat, comm, tty, ppid., rtprio
ni : nice值;
pri : priority , 優先級
rtprio : real time priority, 實時優先級;
pgrep, pkill – look up or signal processes based on name and other attributes
pgrep [options] pattern
-u uid : effective user
-U uid : read user
-t TERMINAL : 與指定的終端相關的進程;
-l : 顯示進程名;
-a : 顯示完整格式的進程名;
-P pid : 顯示
pidof命令:
根據進程名,取其pid
top 命令:
top – display Linux processes
排序:
P: 以占據CPU百分比排序;
M: 以占據內存百分比排序;
T: 累積占用CPU時間排序;
首部信息:
uptime信息: | 命令
內存信息:m命令
退出命令:q
修改刷新時間間隔:s
終止指定的進程: k
uptime命令:顯示系統時間,運行時長 及平均負載;
過去1分鐘、5分鐘和15分鐘的平均負載;
等待運行的進程隊列的長度;
選項:
-d: # :指定刷新時間間隔, 默認3秒;
-b: 以批次方式顯示;
-n # :顯示多少批次;
pkill [options] pattern
原創文章,作者:shadow,如若轉載,請注明出處:http://www.www58058.com/65888
基礎命令希望能熟練掌握,其實關鍵是用這些命令能看出對你診斷有幫助的信息。