DougieLawson wrote: ↑Sat Sep 14, 2019 10:17 pm
Once the network is alive systemd-timesyncd gets the time from an internet time server. It then polls, infrequently, to keep the clock close to the local time of day.
I don't know how it knows the network is alive since systemd-timesyncd apparently normally uses systemd-networkd to determine that and systemd-networkd is not running in Raspbian. I couldn't figure it out but maybe you know?
pi@raspberrypi4B-1:~ $ sudo systemctl status systemd-networkd
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; vendo
Active: inactive (dead)
Docs: man:systemd-networkd.service(8)
It takes quite a while after boot for systemd-timesynd to update the time. One can restart systemd-timesyncd as soon as the desktop is up and get the system time updated within a few seconds.
The other interesting thing I found is that the clock in the toolbar that is part of the LXPanel updates very infrequently. It can take 20 or 30 seconds after systemd-timesyncd has synchronized the system time for the clock on the toolbar to show the correct time.
I think there is a timing issue between when the network is up and systemd-timesynd attempts to synchronize the time. I wrote a desktop entry and a script to restart systemd-timesyncd 10 seconds after the desktop is up. It works fine and the time is synchronized much quicker than otherwise. This also works if you change to ntp, you just restart ntp instead of systemd-timesyncd.
The desktop entry file:
[Desktop Entry]
Name=restart-clock
Type=Application
Exec=/home/pi/bin/restart-clock.sh
/home/pi/bin/restart-clock.sh:
#!/bin/bash
sleep 10
sudo systemctl restart systemd-timesyncd
The only question I have left is how does systemd-timesyncd know when the network is up?