了解 Linux 上 ps -ef 的输出

了解 Linux 上 ps -ef 的输出

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

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

答案1

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

   C     pcpu         cpu utilization

但这是在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).

听起来不错。欲了解更多详情,我们搜索%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).

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

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

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

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

  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...

相关内容