NTP Date and Time Sync failed

Hi,

I installed my DietPi again and new after some problems after the last DietPi-Update.

I have already installed Nginx and other software. After I started the install process the time sync process started. I think it started with this command "systemctl start systemd-timesyncd ". 60 seconds after this an error message occurs and told me to restart the process or change anything in the NTP Config. I canceled the process and the installation started for the software.

How can I solve the error message of DietPi? What can I do?

I used the command "systemctl start systemd-timesyncd " manually and there was no error message!

Maybe there was no network connection when it was probing for the ntp server. Or maybe the ntp server that the name resolved to was unreachable.

To check the time sync working you could force the service is follow

/boot/dietpi/func/run_ntpd 1

And to check logs, you can do

journalctl -u systemd-timesyncd.service
1 Like

Thank you so much!!!
Every time I restarted my Raspberry, I lost the right time… with these commands, it seems to work.

Usually time sync should be done automatically during boot? Which option you set within dietpi-config > 4 : Advanced Options > Time sync mode

1 Like

It was “Boot + Daily (Recommended)” but I switch to “Boot + Hourly”.
Thanks

do you use some low valtage settings? Some RPI have issues with minimum below 600MHz.

No, I keep 600MHz

In this case, time sync should be enough on boot and once a day.

It seems on my 4B the timesync service gets stopped after a while:

â—‹ systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
     Active: inactive (dead) since Mon 2023-10-16 01:25:07 UTC; 14h ago
   Duration: 2.843s
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 1266071 (code=exited, status=0/SUCCESS)
     Status: "Idle."
        CPU: 177ms

Oct 16 01:25:04 DietPi systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Oct 16 01:25:04 DietPi systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Oct 16 01:25:06 DietPi systemd-timesyncd[1266071]: Contacted time server 176.221.42.125:123 (0.debian.pool.ntp.org).
Oct 16 01:25:06 DietPi systemd-timesyncd[1266071]: Initial clock synchronization to Mon 2023-10-16 01:25:06.320526 UTC.
Oct 16 01:25:07 DietPi systemd[1]: Stopping systemd-timesyncd.service - Network Time Synchronization...
Oct 16 01:25:07 DietPi systemd[1]: systemd-timesyncd.service: Deactivated successfully.
Oct 16 01:25:07 DietPi systemd[1]: Stopped systemd-timesyncd.service - Network Time Synchronization.

And my time gets out of sync over and over again and I don’t know why. My timesync is set to boot and daily. I do use some low voltage settings (conservative down to 300 MHz), but I would expect it to hold the time at least. It constantly resets to the wrong time (about 1 hour early).

My system is set to UTC, but I’m located in Germany. Right now it’s 19:11, but my Pi suddenly shows 04:05 PM. I still suspect issues with the time zones. /boot/dietpi/func/run_ntpd 1 will fix the problem temporary, and add the missing hour back.

It will happen again, would love some advice how to debug this issue.

Time sync is done once a day. But your CPU frequency is to low. It needs to be at least 600 and not below. otherwise your system will be to slow to calculate accurate system time and you will run out of sync shortly. It’s a know behaviour for RPi4

Thanks for the explanation. So turning it down to hourly should be fine compromise if I don’t need very accurate times. I rather have it run on low power mode. Thanks.

There is an option within dietpi-config to set hourly time sync

I have a feature request/idea, not sure how easy to achieve. Can we have a configurable delay before the time (e.g. 5 mins) is sync-ed on boot time?

Every time I have power outage, my Pi completes it boot sequence before my modem has time to reconnect to the internet. As a result, the time will be wrong until the next day (currently have the time sync to boot + daily).

The next best option for me is to change the sync to boot + hourly, but a configurable delay would be perfect.

I doubt that such a function will be developed, as this is a very rare case and should only be reserved for a very small number of users.

In your case, you could add a cronjob that is executed on restart. The cronjob entry could look like this

@reboot sleep 300 && /boot/dietpi/func/run_ntpd 1

This waits 5 minutes before triggering time synchronization.

1 Like

Or using the “daemon + drift” option could be a solution?

not sure if this will be an option because initial time sync is already failing due to missing internet connection.

I did a test with an activated “daemon + drift”. Then

  • powering off the system for a while.
  • unplug the LAN cable
  • power on the system and wait until booted
  • login and check that the time/date is outdated ( via date command)
  • plug in the LAN cable

After a short while (I did not monitor it exactly), the time/date was set corrrectly.

1 Like

I just installed Chrony and liking it. If there is a power outage, am I right to assume:

  • the system time will be set to the last saved time (before outage) when power is restored
  • chronyd will try and get the time from configured sources (internet is still down)
  • once online and ntp sync succeeded, chronyd will update the system time

Do I need to add this to my chrony.conf to use the fakehw clock as fallback?

server 127.127.1.0  # Local clock
fudge 127.127.1.0 stratum 10
1 Like

I don’t know because I don’t use Chrony. You should disable DietPi time synchronisation if you continue to use Chrony to avoid conflicts.