如何获取长时间运行的 Linux 进程的启动时间? [英] How to get the start time of a long-running Linux process?

查看:24
本文介绍了如何获取长时间运行的 Linux 进程的启动时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获取旧运行进程的开始时间?似乎 ps 如果今天没有开始,会报告日期(而不是时间),如果今年没有开始,只会报告年份.旧流程会永远失去精度吗?

Is it possible to get the start time of an old running process? It seems that ps will report the date (not the time) if it wasn't started today, and only the year if it wasn't started this year. Is the precision lost forever for old processes?

推荐答案

你可以指定一个格式化程序并使用lstart,就像这个命令:

You can specify a formatter and use lstart, like this command:

ps -eo pid,lstart,cmd

以上命令将输出所有进程,带有格式化程序以获取PID、命令运行和开始日期+时间.

The above command will output all processes, with formatters to get PID, command run, and date+time started.

示例(来自 Debian/Jessie 命令行)

Example (from Debian/Jessie command line)

$ ps -eo pid,lstart,cmd
  PID CMD                                          STARTED
    1 Tue Jun  7 01:29:38 2016 /sbin/init                  
    2 Tue Jun  7 01:29:38 2016 [kthreadd]                  
    3 Tue Jun  7 01:29:38 2016 [ksoftirqd/0]               
    5 Tue Jun  7 01:29:38 2016 [kworker/0:0H]              
    7 Tue Jun  7 01:29:38 2016 [rcu_sched]                 
    8 Tue Jun  7 01:29:38 2016 [rcu_bh]                    
    9 Tue Jun  7 01:29:38 2016 [migration/0]               
   10 Tue Jun  7 01:29:38 2016 [kdevtmpfs]                 
   11 Tue Jun  7 01:29:38 2016 [netns]                     
  277 Tue Jun  7 01:29:38 2016 [writeback]                 
  279 Tue Jun  7 01:29:38 2016 [crypto]                    
      ...

您可以阅读 ps 的联机帮助页或 查看 Opengroup 的页面 用于其他格式化程序.

You can read ps's manpage or check Opengroup's page for the other formatters.

这篇关于如何获取长时间运行的 Linux 进程的启动时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆