Convert the dmesg timestamps to human-readable format on Linux

The dmesg results from newer Linux kernels show the timestamps. the dmesg timestamp is the time in seconds since the kernel starting time.

[root@unixonline]# dmesg
[2593404.865599] vmxnet3 0000:0b:00.0 ens192: intr type 3, mode 0, 5 vectors allocated
[2593404.868590] vmxnet3 0000:0b:00.0 ens192: NIC Link is Up 10000 Mbps
[2593426.220166] vmxnet3 0000:0b:00.0 ens192: intr type 3, mode 0, 5 vectors allocated
[2593426.223232] vmxnet3 0000:0b:00.0 ens192: NIC Link is Up 10000 Mbps

Later dmesg has an -T option:

-T, –ctime
show human readable timestamp (could be inaccurate if you have used SUSPEND/RESUME)
### Be aware that the timestamp could be inaccurate! The time source used for the logs is not updated after system SUSPEND/RESUME.

# dmesg -T
will print the real time stamps.
[root@unixonline]# dmesg -T
[Tue May 31 16:27:57 2022] vmxnet3 0000:0b:00.0 ens192: intr type 3, mode 0, 5 vectors allocated
[Tue May 31 16:27:57 2022] vmxnet3 0000:0b:00.0 ens192: NIC Link is Up 10000 Mbps
[Tue May 31 16:28:19 2022] vmxnet3 0000:0b:00.0 ens192: intr type 3, mode 0, 5 vectors allocated
[Tue May 31 16:28:19 2022] vmxnet3 0000:0b:00.0 ens192: NIC Link is Up 10000 Mbps

Leave a Comment