Wrong time after power off Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
baz123
Posts: 166
Joined: Thu Jan 12, 2017 9:23 pm

Re: Wrong time after power off

Post by baz123 »

@MichaIng Thanks.

One of the issues I had in debugging this was that fake-hwclock does not appear to log what it does on boot.

Timesync does store the date/time in /var/lib/systemd/timesync/clock (https://wiki.archlinux.org/index.php/systemd-timesyncd) and the rate it does that is configurable.

Yes, timesync does need a network to sync, but I think on boot it initially loads the stored time if it is the newest time it has. This is no different to fake-hwclock. However, I found fake-hwclock to unreliably save the current datetime at shutdown.

I was only suggesting the purge if the daemon method was selected i.e. as part of the switch to the daemon method.

Yes it needs to be the only timesync present, but again, this assumes the time control is being handled by the DietPi config. If anyone fiddles with that they deserve issues!

Code: Select all

$  timedatectl show-timesync --all
Returns the datestamp of the last sync or else check the clock file Datestamp.

That item on the RPi forum is quite old - systemd has moved on. Of note is that fake-hwclock does not set the time-sync.target (renamed to time-set in Buster it seems) so services that rely on time, cannot use that to control startup. That it only needs to complete before sysinit.target also implies fake-hwclock may start later.

All I can say is that since purging fake-hwclock and reducing the timesyncd poll time to 60s, I have had far fewer issues with time at startup!
somenrs
Posts: 11
Joined: Fri Jul 03, 2020 11:08 am

Re: Wrong time after power off

Post by somenrs »

Has the time sync issue been resolved? I have tried literally everything in this topic and on internet and still cannot get current time from any server, router, wifi, santaclaus...
User avatar
Joulinar
Posts: 2616
Joined: Sat Nov 16, 2019 12:49 am

Re: Wrong time after power off

Post by Joulinar »

Hi,

usually there is no time sync issue. Pls can you check what the following give to you

Code: Select all

/boot/dietpi/func/run_ntpd 1
systemctl status systemd-timesyncd.service
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
somenrs
Posts: 11
Joined: Fri Jul 03, 2020 11:08 am

Re: Wrong time after power off

Post by somenrs »

/boot/dietpi/func/run_ntpd 1 returns this:

Code: Select all

...
[ INFO ] DietPi-Run_NTPD | Waiting for completion of systemd-timesyncd (60/60)
[ INFO ] DietPi-Run_NTPD | Timed out waiting for systemd-timesyncd
systemctl status systemd-timesyncd.service returns this:

Code: Select all

● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; disabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: active (running) since Wed 2020-09-09 14:17:01 CEST; 31s ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 12362 (systemd-timesyn)
   Status: "Connecting to time server 216.239.35.4:123 (time.google.com)."
    Tasks: 2 (limit: 2013)
   CGroup: /system.slice/systemd-timesyncd.service
           └─12362 /lib/systemd/systemd-timesyncd

sep 09 14:17:01 DietPi systemd[1]: Starting Network Time Synchronization...
sep 09 14:17:01 DietPi systemd[1]: Started Network Time Synchronization.
sep 09 14:17:12 DietPi systemd-timesyncd[12362]: Timed out waiting for reply from 216.239.35.8:123 (time.google.com).
sep 09 14:17:22 DietPi systemd-timesyncd[12362]: Timed out waiting for reply from 216.239.35.0:123 (time.google.com).
sep 09 14:17:32 DietPi systemd-timesyncd[12362]: Timed out waiting for reply from 216.239.35.12:123 (time.google.com).
It doesn't matter what server I use, the result is always the same.

Oh, I did not yet ask our IT guys if company's firewall or router is blocking ntp packets.
User avatar
Joulinar
Posts: 2616
Joined: Sat Nov 16, 2019 12:49 am

Re: Wrong time after power off

Post by Joulinar »

Oh, I did not yet ask our IT guys if company's firewall or router is blocking ntp packets.
Or you have a time server in your local network. But I guess your IT guys will know.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 2423
Joined: Sat Nov 18, 2017 6:21 pm

Re: Wrong time after power off

Post by MichaIng »

I hope there is a local time server, e.g. the router itself? Not uncommon and recommended especially for larger local networks so that not each and every client needs to sync with public time servers, which unnecessarily increases their load and sync time for all clients.

If otherwise network connection works fine, e.g. you can ping the time server you tested ping 216.239.35.4 then closed UDP port 123 would be my next guess as well.
somenrs
Posts: 11
Joined: Fri Jul 03, 2020 11:08 am

Re: Wrong time after power off

Post by somenrs »

It turned out our company's network is the reason for time not syncing. Thanks for all your help.
Post Reply