Date Time issues rPi4

Hi @SimonE

Currently I Have this running, which seems to do the trick for me on a rPi4, bypassing the script. All in the service.
I know the sleep is all but elegant, but I experienced the same issue as @eMCZe mentioned. 7 out of 10 it worked, but not consistent.

sudo nano /lib/systemd/system/setdatetime.service

[Unit]
Description=Set local time using time server

[Service]
Type=oneshot
ExecStart=/bin/bash -c "sleep 30; /usr/bin/sudo /bin/date -s \"$(/usr/bin/curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')\""

[Install]
WantedBy=multi-user.target

ctrl+o, ctrl+x

sudo chmod 644 /lib/systemd/system/setdatetime.service && sudo systemctl daemon-reload && sudo systemctl enable setdatetime.service && sudo systemctl start setdatetime.service

1 Like