当我执行“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.