这对以前引导的过去正常运行时间没有帮助,但您现在可以开始记录正常运行时间,方法是安装诸如此类的工具uptimed并对其进行设置,使其永远不会丢弃值(LOG_MAXIMUM_ENTRIES在 中设置为 0 uptimed.conf)。这将测量操作系统的正常运行时间,而不是 CPU “开启”时间,但它应该足够接近......一旦你开始uptimed运行,你可以运行uprecords以查看总数,例如
up 1492 days, 02:57:18 | since Sat Sep 7 00:50:06 2013
down 61 days, 08:11:24 | since Sat Sep 7 00:50:06 2013
%up 96.051 | since Sat Sep 7 00:50:06 2013
如果您从操作系统获取该信息没有问题,您可以使用tuptime查看 linux 系统总时间的完整报告,包括系统崩溃。
例如,作为默认输出和恢复:
# tuptime
System startups: 8 since 08:32:29 AM 11/24/2016
System shutdowns: 3 ok - 4 bad
System uptime: 99.99 % - 1 year, 195 days, 5 hours, 47 minutes and 14 seconds
System downtime: 0.01 % - 1 hour, 6 minutes and 34 seconds
System life: 1 year, 195 days, 6 hours, 53 minutes and 48 seconds
Largest uptime: 240 days, 7 hours, 38 minutes and 10 seconds from 08:41:51 AM 02/07/2017
Shortest uptime: 18 hours, 15 minutes and 14 seconds from 02:26:05 PM 02/06/2017
Average uptime: 70 days, 0 hours, 43 minutes and 24 seconds
Largest downtime: 45 minutes and 15 seconds from 10:00:01 AM 03/14/2018
Shortest downtime: 5 seconds from 02:26:00 PM 02/06/2017
Average downtime: 9 minutes and 31 seconds
Current uptime: 85 days, 4 hours, 41 minutes and 1 second since 10:45:16 AM 03/14/2018
或者,可以使用 list 参数获取包含所有历史事件的列表,其中您可以了解关闭事件、坏(崩溃)或正常(关闭过程之后)的情况:
# tuptime -l
Startup: 1 at 08:32:29 AM 11/24/2016
Uptime: 46 days, 16 hours, 52 minutes and 32 seconds
Shutdown: BAD at 01:25:01 AM 01/10/2017
Downtime: 5 minutes and 10 seconds
Startup: 2 at 01:30:11 AM 01/10/2017
Uptime: 27 days, 12 hours, 55 minutes and 49 seconds
Shutdown: OK at 02:26:00 PM 02/06/2017
Downtime: 5 seconds
Startup: 3 at 02:26:05 PM 02/06/2017
Uptime: 18 hours, 15 minutes and 14 seconds
Shutdown: OK at 08:41:19 AM 02/07/2017
Downtime: 32 seconds
Startup: 4 at 08:41:51 AM 02/07/2017
Uptime: 240 days, 7 hours, 38 minutes and 10 seconds
Shutdown: BAD at 05:20:01 PM 10/05/2017
Downtime: 3 minutes and 17 seconds
Startup: 5 at 05:23:18 PM 10/05/2017
Uptime: 7 days, 14 hours, 56 minutes and 43 seconds
Shutdown: BAD at 08:20:01 AM 10/13/2017
Downtime: 11 minutes and 35 seconds
Startup: 6 at 08:31:36 AM 10/13/2017
Uptime: 25 days, 1 hour, 7 minutes and 4 seconds
Shutdown: OK at 08:38:40 AM 11/07/2017
Downtime: 39 seconds
Startup: 7 at 08:39:19 AM 11/07/2017
Uptime: 127 days, 1 hour, 20 minutes and 42 seconds
Shutdown: BAD at 10:00:01 AM 03/14/2018
Downtime: 45 minutes and 15 seconds
Startup: 8 at 10:45:16 AM 03/14/2018
Uptime: 85 days, 4 hours, 42 minutes and 9 seconds
据我所知,这不是固件跟踪的内容。甚至 BMC 也不测量总正常运行时间。
这对以前引导的过去正常运行时间没有帮助,但您现在可以开始记录正常运行时间,方法是安装诸如此类的工具
uptimed
并对其进行设置,使其永远不会丢弃值(LOG_MAXIMUM_ENTRIES
在 中设置为 0uptimed.conf
)。这将测量操作系统的正常运行时间,而不是 CPU “开启”时间,但它应该足够接近......一旦你开始uptimed
运行,你可以运行uprecords
以查看总数,例如正如quixotic所指出的,您可以通过查看日志来了解历史正常运行时间。如果您正在运行 systemd,您可以查看已使用
journalctl --list-boots
. 日志轮换意味着这可能会错过相当多的正常运行时间。正如JdeBP所指出的,
last reboot
可能会为您提供更长的靴子列表以及相关的正常运行时间。如果您从操作系统获取该信息没有问题,您可以使用tuptime查看 linux 系统总时间的完整报告,包括系统崩溃。
例如,作为默认输出和恢复:
或者,可以使用 list 参数获取包含所有历史事件的列表,其中您可以了解关闭事件、坏(崩溃)或正常(关闭过程之后)的情况:
考虑到这一点
last reboot
并journalctl --list-boots
从日志中获取信息,这些日志具有最长寿命。相反,tuptime
将信息存储在专用于它的特定数据库文件中。对于安装,假设您使用 Linux,该软件包在 Debian 及其衍生版本中可用:
如果没有,您可以从存储库中获取安装脚本“tuptime-install.sh”: https ://github.com/rfrail3/tuptime/