如何将 dmesg 时间戳转换为自定义日期格式? [英] How do I convert dmesg timestamp to custom date format?

查看:60
本文介绍了如何将 dmesg 时间戳转换为自定义日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图理解 dmesg 时间戳,发现很难将其转换为 Java 日期/自定义日期格式.

I am trying to understand the dmesg timestamp and find it hard to convert that to change it to java date/custom date format.

示例 dmesg 日志:

Sample dmesg log:

[14614.647880] airo(eth1): link lost (missed beacons)

那么如何将 14614.647880 转换为标准日期?

So how do I convert 14614.647880 to a standard date?

推荐答案

理解 dmesg 时间戳非常简单:它是内核启动后的秒数.因此,有了启动时间 (uptime),您可以将秒数相加并以您喜欢的任何格式显示它们.

Understanding dmesg timestamp is pretty simple: it is time in seconds since the kernel started. So, having time of startup (uptime), you can add up the seconds and show them in whatever format you like.

或者更好的是,您可以使用 dmesg-T 命令行选项并解析人类可读的格式.

Or better, you could use the -T command line option of dmesg and parse the human readable format.

来自手册页:

-T, --ctime
    Print human readable timestamps. The timestamp could be inaccurate!

    The time source used for the logs is not updated after system SUSPEND/RESUME.

这篇关于如何将 dmesg 时间戳转换为自定义日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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