Re: turn on timestamps in kernel log messages?

From: Pete Wright <pete_at_nomadlogic.org>
Date: Sun, 28 Aug 2022 16:57:15 UTC
On Sun, Aug 28, 2022 at 04:07:39PM +0100, void wrote:
> Hello,
> 
> In periodic daily emails it's recorded if there's anything
> in kernel log messages during the last 24 hrs. The problem
> is that the lines pertaining to these messages aren't timestamped
> so the information is of less use in tracking down a problem
> than it could be. Example:
> 
> +pid 96879 (conftest), jid 8779, uid 0: exited on signal 11 (core dumped)
> +tap2: link state changed to DOWN +swap_pager: out of swap space
> +swp_pager_getswapspace(7): failed
> 
> In the same email, login failures are timestamped.
> 
> Is there a way to have kernel log messages timestamped so they appear as
> such in periodic daily emails?
> 

i think you are looking for the kern.msgbuf_show_timestamp sysctl knob:

via dmesg(8)
kern.msgbuf_show_timestamp: 0
             If set to 0, no timetamps are added.  If set to 1, then a
             1-second granularity timestamp will be added to most lines in the
             message buffer.  If set to 2, then a microsecond granularity
             timestamp will be added.  This may also be set as a boot
             loader(8) tunable.  The timestamps are placed at the start of
             most lines that the kernel generates.  Some multi-line messages
             will have only the first line tagged with a timestamp.

-pete

-- 
Pete Wright
pete@nomadlogic.org