3

I am often using dmesg to monitor the log when a new USB device is attached. I often "tail" it with timestamps using dmesg -Tw. However right now the timestamps are wrong.

So for example, here's the date right now:-

alan@gort:~$ date
Tue  6 Dec 12:10:59 GMT 2016

I just attached a device and note the date:-

[Mon Nov 28 02:51:24 2016] hid-generic 0003:16C0:0482.0010: input,hidraw2: USB HID v1.11 Mouse [Teensy Keyboard/Mouse/Joystick] on usb-0000:00:14.0-1.2/input1
[Mon Nov 28 02:51:24 2016] hid-generic 0003:16C0:0482.0011: hidraw3: USB HID v1.11 Device [Teensy Keyboard/Mouse/Joystick] on usb-0000:00:14.0-1.2/input2
[Mon Nov 28 02:51:24 2016] input: Teensy Keyboard/Mouse/Joystick as /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.2/2-1.2:1.3/0003:16C0:0482.0012/input/input33
[Mon Nov 28 02:51:24 2016] hid-generic 0003:16C0:0482.0012: input,hidraw4: USB HID v1.11 Joystick [Teensy Keyboard/Mouse/Joystick] on usb-0000:00:14.0-1.2/input3

Why isn't the log output correct?

2
  • 1
    The manpage says Be aware that the timestamp could be inaccurate! The time source used for the logs is not updated after system SUSPEND/RESUME. Maybe your system was suspended before?
    – ridgy
    Dec 6, 2016 at 12:32
  • Oh! You're right. I suspend all the time. Well done.
    – popey
    Dec 6, 2016 at 12:37

2 Answers 2

3

ridgy posted a comment explaining this, and the original poster has verified that the explanation is correct:

The manpage (man dmesg) says:

Be aware that the timestamp could be inaccurate! The time source used for the logs is not updated after system SUSPEND/RESUME.

Maybe your system was suspended before?

2

Workaround is journalctl with -k, --dmesg. I am using -k as it is shorter:

journalctl -k

It will show only kernel messages and correct time.

To show only kernel lines matching phrase:

journalctl -kg phrase

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .