访问手机版  

Linux常用命令|Linux培训学习|考试认证|工资待遇与招聘,认准超级网工!

招聘|合作 登陆|注册

网络工程师培训

当前位置:网络工程师 > 技术课程 > linux > 热点关注 > linux常用命令

Linux ps 命令查看进程启动及运行时间

时间:2019-07-23

linux解压命令_linux命令windows命令_linux命令

Linux ps 命令查看进程启动及运行时间

同事问我怎样看一个进程的启动时间和运行时间,我第一反应当然是说用 ps 命令啦。

ps aux或ps -ef不就可以看时间吗?

我们来重新复习下ps aux的选项,这是类 BSD 风格的命令选项,因为不带“-”。

通过 man 可以看到 aux 选项解释如下:

linux解压命令_linux命令windows命令_linux命令

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.