了解 ps -ef 在 linux 上的输出

xyz*_*xyz 0 linux process administration system-information

当我在 Linux 机器上执行 ps -ef 时,我得到: UID PID PPID C STIME TTY TIME CMD

请帮我理解 C,TIME 的含义。是 TIME ,分配给进程的实际 CPU 时间?

Mik*_*kel 7

如果您运行man ps然后键入/SpaceShift+CSpaceEnter,您应该会看到这一行。

   C     pcpu         cpu utilization
Run Code Online (Sandbox Code Playgroud)

但这在OBSOLETE SORT KEYS标题下,所以不是我们要找的。

n查找下一个匹配项:

   c           C         processor utilization. Currently, this is the
                         integer value of the percent usage over the
                         lifetime of the process.
                         (see %cpu).
Run Code Online (Sandbox Code Playgroud)

听起来不错。有关更多详细信息,我们搜索%cpu并找到:

   %cpu        %CPU      cpu utilization of the process in "##.#" format.
                         Currently, it is the CPU time used divided by the
                         time the process has been running cputime/realtime
                         ratio), expressed as a percentage. ...
                         (alias pcpu).
Run Code Online (Sandbox Code Playgroud)

并且TIME有两个匹配项,但只有一个匹配hh:mm:ss格式:

   cputime     TIME      cumulative CPU time, "[DD-]hh:mm:ss" format. (alias time).
Run Code Online (Sandbox Code Playgroud)

累积 CPU 时间是处理器运行进程所花费的时间量,即实际使用 CPU 周期,而不是休眠、等待运行或等待 I/O。

它是通过对proc(5) 手册页中描述的utimestime值求和来确定的。

  utime %lu   Amount of time that this process has been scheduled in user mode...
  stime %lu   Amount of time that this process has been scheduled in kernel mode...
Run Code Online (Sandbox Code Playgroud)