Thomas' Tech Tips

How to enable timestamps in dmesg

30 October 2022 - Thomas Damgaard

In Linux, the dmesg command is used to print the Linux kernel ring buffer. On many systems, dmesg does not print any timestamps on the messages.

Whether timestamps are shown or not is controlled by /sys/module/printk/parameters/time

To enable timestamps in dmesg, run

echo 1 >  /sys/module/printk/parameters/time

To disable timestamps in dmesg, run

echo 0 >  /sys/module/printk/parameters/time

Alternatively, you can use the following options when invoking dmesg:

 -d, --show-delta            show time delta between printed messages
 -e, --reltime               show local time and time delta in readable format
 -T, --ctime                 show human-readable timestamp (may be inaccurate!)
 -t, --notime                don't show any timestamp with messages
     --time-format <format>  show timestamp using the given format:
                               [delta|reltime|ctime|notime|iso]

Note: Suspending/resume will make ctime and iso timestamps inaccurate.

Filed under: linux, tips

Back to article list