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

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

问题描述

是否有可能得到一个古老的正在运行的进程的开始时间?看来, PS 将报告,如果它不是今年开工日期(无时间)今天,如果它没有启动,只有一年。是precision永远失去了旧流程?

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?

推荐答案

您可以指定格式,并使用 ETIME ,像这样的命令:

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

PS -eo PID,CMD,ETIME

上面的命令将输出的所有进程,格式化得到PID,运行的命令,以及经过时间。

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

您可以阅读 PS 的手册页或查看页面其他格式化:
<一href=\"http://pubs.opengroup.org/onlinepubs/000095399/utilities/ps.html\">http://pubs.opengroup.org/onlinepubs/000095399/utilities/ps.html

You can read ps's manpage or check this page for the other formatters: http://pubs.opengroup.org/onlinepubs/000095399/utilities/ps.html

例如:

[birryree@lilun ~]$ ps -eo pid,cmd,etime
  213 [crypto/0]                  52-15:07:00
  214 [crypto/1]                  52-15:07:00
  215 [crypto/2]                  52-15:07:00
  216 [crypto/3]                  52-15:07:00
  ...

我的机器一直为52+天,所以这些进程已经运行了很久。

My machine's been up for 52+ days, so these processes have been running that long.

不同的系统,运行Fedora:

Different system, running Fedora:

[root@domU-12-31-39-00-64-B5 ~]# ps -eo pid,cmd,etime
  PID CMD                             ELAPSED
    1 init [4]                    707-20:49:44
    2 [migration/0]               707-20:49:44
    3 [ksoftirqd/0]               707-20:49:44

机器已高达近2年,所以这些进程是运行时间最长的。

Machine's been up nearly 2 years, so these processes are the longest running.

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

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