ps命令中其實提供了相應參數,使用man ps查看(養成linux命令行下查看man手冊的習慣)
話不多說,直接上命令。
[root@test root]# ps -eo pid,lstart,etime,cmd | grep nginx
336 Fri Aug 17 14:00:13 2018 311-01:29:08 nginx: master process /opt/app/tengine/sbin/nginx
1583 Sun Jun 23 00:00:00 2019 1-15:29:21 nginx: worker process is shutting down
13412 Mon Jun 24 00:00:00 2019 15:29:21 nginx: worker process
13413 Mon Jun 24 00:00:00 2019 15:29:21 nginx: worker process
21087 Mon Jun 24 15:29:21 2019 00:00 grep --color=auto nginx
22198 Sat Jun 22 00:00:00 2019 2-15:29:21 nginx: worker process is shutting down
命令解析:
-e 顯示所有進程
-o 自定義顯示格式
pid 顯示進程ID
lstart 進程啓動時的精確時間(長格式顯示)
etime 進程啓動後至今所流逝的時間
cmd 顯示進程啓動的命令