Raspberry pi - ntp - syslog

2 posts / 0 new
Last post
#1 Tue, 2018-02-27 11:44
mickesommar
  • mickesommar's picture
  • Offline
  • Last seen: 3 weeks 5 days ago
  • Joined: 2018-02-27

Hi

I have installed the raspberry pi image. On two differens pi:s. I use "in memory"-installation.
I have tried both chrony and busybox ntp clients. The time will be updated during a boot.

The problem is that /var/log/messages will use old-unix-time. So all the logs will have the same timestamp.
I have tried to rebood the klogd daemon, it fails. But I can se the correct time-stamp in the /var/log/messages then the daemon is rebooted.
But it will go back to old-unix-time-stamp.

Any ideas?

// Micke

Fri, 2018-03-02 12:52
mickesommar
  • mickesommar's picture
  • Offline
  • Last seen: 3 weeks 5 days ago
  • Joined: 2018-02-27

Hi All

I have not find a solution yet, but a "workaround".
The syslogd-daemon is implemented in busybox. The ntpd-daemon is alos implemented in busybox.
But the syslogd get the wrong time (old unix-time), even if the ntp-client get the correct time in "userland".

The alpine-developer had to create a patch to prevent to get the wrong time-format from "userland":
https://git.alpinelinux.org/cgit/aports/tree/main/busybox/0009-sysklogd-add-Z-option-to-adjust-message-timezones.patcha

Some syslog() implementations like musl's[1] always send timestamps in UTC.
This change adds a new option to syslogd, -Z, to assume incoming timestamps
are always UTC and adjust them to the local timezone (of the syslogd) before
logging.

The patch will add a -Z flag to syslogd. This flag will try to get the time from the "localtime" insdeed. This is a problem with the Raspberry Pi (RPI).
The RPI does not have a "hardware clock", so I think it is a bug in the -Z implemantation for RPI:s.

I'm living in Sweden, we have timezone "Europe/Stockholm" (+01).

My workaround is to change timezone to UTC in userland, and remove the -Z flag in /etc/config.d/syslog .
The time in userland will be UTC, but also in all the log-files. I can live with one hour off, better then the same time-stamp on all log-entrys.

// Micke

Log in or register to post comments