
當我執行「top」時,我了解到有許多進程正在運行,其中許多進程處於睡眠狀態。我需要查看當時所有進程的完整快照。 「頂部」能夠顯示適合一個螢幕的進程清單。
除此之外,我有興趣查看處於「睡眠」狀態的所有進程的清單。我不認為我可以在“ps”命令的輸出中獲取進程狀態
答案1
top -b
似乎正在做這件事。
答案2
您可以使用 coreutils 來取得進程狀態ps
$ ps aux
將列出所有這些,甚至更多。以下是如何從手冊頁中解碼它們:
過程狀態代碼
以下是 s、stat 和 state 輸出說明符(標題「STAT」或「S」)將顯示的不同值,用於描述進程的狀態:
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.
對於 BSD 格式並且使用 stat 關鍵字時,可能會顯示其他字元:
< 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.