Linux ps 命令查看进程启动及运行时间
同事问我怎样看一个进程的启动时间和运行时间,我第一反应当然是说用 ps 命令啦。
ps aux或ps -ef不就可以看时间吗?
我们来重新复习下ps aux的选项,这是类 BSD 风格的命令选项,因为不带“-”。
通过 man 可以看到 aux 选项解释如下:
a Lift the BSD-style "only yourself" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An alternate description is that this option causes ps to list all processes with a terminal (tty), or to list all processes when used together with the x option. x Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An alternate description is that this option causes ps to list all processes owned by you (same EUID as ps), or to list all processes when used together with the a option. u Display user-oriented format.
然后再来看下ps aux的输出结果,其首行如下,说明了输出的各列:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
我们可以看到START和TIME列linux命令,通过 man 其说明如下:
bsdstart START time the command started. If the process was started less than 24 hours ago, the output format is " HH:MM", else it is " Mmm:SS" (where Mmm is the three letters of the month). See also lstart, start, start_time, and stime. bsdtime TIME accumulated cpu time, user + system. The display format is usually "MMM:SS", but can be shifted to the right if the process used more than 999 minutes of cpu time.
上一个教程:linux常见命令之grep命令详解
下一个教程:Linux命令(八)之安装Jdk、Tomcat