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列l(wèi)inux命令,通過 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