Linux下顯示系統(tǒng)進(jìn)程的命令ps,最常用的有ps -ef 和ps aux。這兩個到底有什么區(qū)別呢?兩者沒太大差別,討論這個問題,要追溯到Unix系統(tǒng)中的兩種風(fēng)格,
System V風(fēng)格和BSD 風(fēng)格,ps aux最初用到Unix Style中,而ps -ef被用在System V Style中,兩者輸出略有不同?,F(xiàn)在的大部分Linux系統(tǒng)都是可以同時使用這兩種方式的。
ps -ef
ps -ef 是用標(biāo)準(zhǔn)的格式顯示進(jìn)程的、其格式如下
[root@69e52c4fa4d1 /]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 16:27 ? 00:00:00 /bin/sh /start.sh
root 10 1 0 16:27 ? 00:00:01 /usr/bin/python /usr/bin/supervisord -n -c /etc/supervisord.conf
root 13 10 0 16:27 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
root 14 10 0 16:27 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
www 21 13 0 16:27 ? 00:00:00 php-fpm: pool www
www 22 13 0 16:27 ? 00:00:00 php-fpm: pool www
root 153 0 0 17:37 pts/0 00:00:00 bash
www 189 14 0 17:44 ? 00:00:00 nginx: worker process
www 190 14 0 17:44 ? 00:00:00 nginx: worker process
www 191 14 0 17:44 ? 00:00:00 nginx: worker process
www 192 14 0 17:44 ? 00:00:00 nginx: worker process
www 193 14 0 17:44 ? 00:00:00 nginx: worker process
www 194 14 0 17:44 ? 00:00:00 nginx: worker process
root 197 153 0 17:44 pts/0 00:00:00 ps -ef
其中各列的內(nèi)容意思如下
UID //用戶ID、但輸出的是用戶名
PID //進(jìn)程的ID
PPID //父進(jìn)程ID
C //進(jìn)程占用CPU的百分比
STIME //進(jìn)程啟動到現(xiàn)在的時間
TTY //該進(jìn)程在那個終端上運行,若與終端無關(guān),則顯示? 若為pts/0等,則表示由網(wǎng)絡(luò)連接主機進(jìn)程。
CMD //命令的名稱和參數(shù)
ps aux
ps aux 是用BSD的格式來顯示、其格式如下
[root@69e52c4fa4d1 /]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 11688 2500 ? Ss 16:27 0:00 /bin/sh /start.sh
root 10 0.0 0.7 114044 16028 ? S 16:27 0:01 /usr/bin/python /usr/bin/supervisord -n -c /etc/supervisord.conf
root 13 0.0 0.8 113808 17336 ? S 16:27 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
root 14 0.0 0.3 45996 6204 ? S 16:27 0:00 nginx: master process /usr/local/nginx/sbin/nginx
www 21 0.0 0.7 113872 14740 ? S 16:27 0:00 php-fpm: pool www
www 22 0.0 0.7 113872 14740 ? S 16:27 0:00 php-fpm: pool www
root 153 0.0 0.1 11828 3020 pts/0 Ss 17:37 0:00 bash
www 189 0.0 1.2 67608 25116 ? S 17:44 0:00 nginx: worker process
www 190 0.0 1.2 67608 25116 ? S 17:44 0:00 nginx: worker process
www 191 0.0 1.2 67608 25116 ? S 17:44 0:00 nginx: worker process
www 192 0.0 1.2 67608 24720 ? S 17:44 0:00 nginx: worker process
www 193 0.0 1.2 67608 25116 ? S 17:44 0:00 nginx: worker process
www 194 0.0 1.2 67608 24720 ? S 17:44 0:00 nginx: worker process
root 198 0.0 0.1 51716 3468 pts/0 R+ 17:45 0:00 ps aux
同ps -ef 不同的有列有
USER //用戶名
%CPU //進(jìn)程占用的CPU百分比
%MEM //占用內(nèi)存的百分比
VSZ //該進(jìn)程使用的虛擬內(nèi)存量(KB)
RSS //該進(jìn)程占用的固定內(nèi)存量(KB)(駐留中頁的數(shù)量)
STAT //進(jìn)程的狀態(tài)
START //該進(jìn)程被觸發(fā)啟動時間
TIME //該進(jìn)程實際使用CPU運行的時間
其中STAT狀態(tài)位常見的狀態(tài)字符有
D //無法中斷的休眠狀態(tài)(通常 IO 的進(jìn)程);
R //正在運行可中在隊列中可過行的;
S //處于休眠狀態(tài);
T //停止或被追蹤;
W //進(jìn)入內(nèi)存交換 (從內(nèi)核2.6開始無效);
X //死掉的進(jìn)程 (基本很少見);
Z //僵尸進(jìn)程;
< //優(yōu)先級高的進(jìn)程
N //優(yōu)先級較低的進(jìn)程
L //有些頁被鎖進(jìn)內(nèi)存;
s //進(jìn)程的領(lǐng)導(dǎo)者(在它之下有子進(jìn)程);
l //多線程,克隆線程(使用 CLONE_THREAD, 類似 NPTL pthreads);
+ //位于后臺的進(jìn)程組;
內(nèi)容來自https://www.cnblogs.com/5201351/p/4206461.html,改變的是圖片替換為文字例子