Linux ps -o 查看进程启动时间

时间参数


  • 如下表
    参数    含义
    start 显示进程启动时间的简短格式。通常,它会显示日期时间中的月-日 或者 时-分-秒
    start_time  显示进程启动时间的简短格式,通常格式是 年 或者  月-日 或者  时-分,没有秒
    etime 显示进程启动的累积时间,通常格式是 天-时-分-秒
    etimes 显示进程启动的累积时间,通常格式是以秒为单位
    lstart 显示进程的启动时间的长格式,通常格式是 星期-月-日 时-分-秒 年
    stime 表示进程在内核态(Kernel Mode)运行的累计时间。内核态是指进程在执行系统调用或其他内核相关操作时所处的运行模式,通常格式是 年 或者  月-日 或者  时-分,没有秒

具体使用方法


  1. 执行命令

    [21:34:37] root@test-b5-nginx-33-102:/etc/tengine # ps -eo pid,start,lstart,%cpu,start_time,etime,cmd | head -n 1 && ps -eo pid,start,lstart,%cpu,start_time,etime,cmd  | grep nginx
      PID  STARTED                  STARTED %CPU START     ELAPSED CMD
     4470 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4471 20:37:01 Fri Jul 21 20:37:01 2023  0.1 20:37    01:00:17 nginx: worker process
     4472 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4473 20:37:01 Fri Jul 21 20:37:01 2023  0.3 20:37    01:00:17 nginx: worker process
     4474 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4475 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4476 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4477 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4478 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4479 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4480 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4481 20:37:01 Fri Jul 21 20:37:01 2023  0.1 20:37    01:00:17 nginx: worker process
     4482 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4483 20:37:01 Fri Jul 21 20:37:01 2023  0.3 20:37    01:00:17 nginx: worker process
     4484 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4485 20:37:01 Fri Jul 21 20:37:01 2023  0.2 20:37    01:00:17 nginx: worker process
     4486 20:37:01 Fri Jul 21 20:37:01 2023  0.6 20:37    01:00:17 nginx: worker process
     4487 20:37:01 Fri Jul 21 20:37:01 2023  0.3 20:37    01:00:17 nginx: worker process
     4488 20:37:01 Fri Jul 21 20:37:01 2023  1.8 20:37    01:00:17 nginx: worker process
     4489 20:37:01 Fri Jul 21 20:37:01 2023  0.9 20:37    01:00:17 nginx: worker process
     4490 20:37:01 Fri Jul 21 20:37:01 2023  5.6 20:37    01:00:17 nginx: worker process
     4491 20:37:01 Fri Jul 21 20:37:01 2023 10.2 20:37    01:00:17 nginx: worker process
     4492 20:37:01 Fri Jul 21 20:37:01 2023 15.9 20:37    01:00:17 nginx: worker process
     4493 20:37:01 Fri Jul 21 20:37:01 2023 19.1 20:37    01:00:17 nginx: worker process
     5968   Jun 29 Thu Jun 29 12:22:34 2023  0.0 6月29 22-09:14:44 nginx: master process /usr/sbin/nginx
    19489 21:37:18 Fri Jul 21 21:37:18 2023  0.0 21:37       00:00 grep --color=auto nginx
  2. ps -eo start,cmd

    月-日格式
     PID  STARTED CMD
        1   Nov 20 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
        2   Nov 20 [kthreadd]
        3   Nov 20 [rcu_gp]
        4   Nov 20 [rcu_par_gp]

    时-分-秒格式

     4480 20:37:01 nginx: worker process
     4481 20:37:01 nginx: worker process
     4482 20:37:01 nginx: worker process
     4483 20:37:01 nginx: worker process
     4484 20:37:01 nginx: worker process

     

  3. ps -eo pid,start_time,cmd

    月-日格式

    37871 7月19 [kworker/u96:2-e]

    时-分格式

    41143 10:06 [kworker/33:2-ev]
    41791 19:51 [kworker/32:2-cg]
    42044 19:52 [kworker/38:0-ev]

     

常用查询参数


  1. ps -eo pid,lstart,etime,cmd | head -n 1 && ps -eo pid,lstart,etime,cmd

    [21:45:12] root@test-b5-nginx-33-102:/etc/tengine # ps -eo pid,lstart,etime,cmd | head -n 1 && ps -eo pid,lstart,etime,cmd | grep nginx
      PID                  STARTED     ELAPSED CMD
     4470 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4471 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4472 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4473 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4474 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4475 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4476 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4477 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4478 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4479 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4480 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4481 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4482 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4483 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4484 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4485 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4486 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4487 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4488 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4489 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4490 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4491 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
     4492 Fri Jul 21 20:37:01 2023    01:08:22 nginx: worker process
posted @ 2023-07-21 21:23  MacoPlus  阅读(965)  评论(0编辑  收藏  举报