[Linux] ps 輸出的 process state 意義

[Linux] ps 輸出的 process state 意義

在 Linux 上常常用 ps 這個指令來看 process 的狀態,

有時會需要知道這個 process 目前的 state 是什麼,

一般簡單的會知道,像是 T 是代表暫停了,但還有很多其他的…

像是下面有一堆 S<s, S+ 有的沒的,到底是什麼意思?

testuser@localhost ~ $ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  19360  1536 ?        Ss   Jan14   0:04 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Jan14   0:00 [kthreadd]
root        60  0.0  0.0      0     0 ?        SN   Jan14   0:00 [ksmd]
root       410  0.0  0.0      0     0 ?        D    Jan14   0:21 [jbd2/dm-0-8]
root       510  0.0  0.0  11272  1384 ?        S<s  Jan14   0:01 /sbin/udevd -d
root      1708  0.0  0.0  93132   896 ?        S<sl Jan14   0:03 auditd
root      1738  0.0  0.0 257680  3012 ?        Sl   Jan14   0:07 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
dbus      1823  0.0  0.0  98332  2400 ?        Ssl  Jan14   0:13 dbus-daemon --system
root      1835  0.0  0.0  93776  5252 ?        Ssl  Jan14   0:04 NetworkManager --pid-file=/var/run/NetworkManager/NetworkManager.pid
root      2557  0.0  0.0   4064   548 tty2     Ss+  Jan14   0:00 /sbin/mingetty /dev/tty2
rtkit     2860  0.0  0.0 168456  1188 ?        SNl  Jan14   0:12 /usr/libexec/rtkit-daemon
root      3013  0.0  0.0  11932  2280 ?        S<   Jan14   0:01 /sbin/udevd -d
testuser  3790  0.0  0.0      0     0 ?        Z    11:45   0:00 [python] <defunct>
testuser  7372  0.0  0.0 115460  2120 pts/4    S+   Jan14   0:06 /usr/bin/expect -f /home/testuser/ssh_default.exp
testuser  7549  0.0  0.0 110240  1120 pts/34   R+   15:58   0:00 ps aux

 

其實查一下 man ps 就可以看到說明了,對照一下就很清楚囉~

D    Uninterruptible sleep (usually IO)
R    Running or runnable (on run queue)
S    Interruptible sleep (waiting for an event to complete)
T    Stopped, either by a job control signal or because it is being traced.
W    paging (not valid since the 2.6.xx kernel)
X    dead (should never be seen)
Z    Defunct ("zombie") process, terminated but not reaped by its parent.
For BSD formats and when the stat keyword is used, additional characters may be displayed:
<    high-priority (not nice to other users)
N    low-priority (nice to other users)
L    has pages locked into memory (for real-time and custom IO)
s    is a session leader
l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+    is in the foreground process group

 

 

(本頁面已被瀏覽過 5,671 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料