RPIWnivarna
Posts: 7
Joined: Sun May 27, 2018 3:16 am
Location: Victoria, Australia

(Solved) Time sync problem

Sat Sep 08, 2018 11:48 am

Hi,

I have had this problem with the pis not syncing time properly, all posts on forums are form years ago that I have found and really want to get this solved.

I want to make my wife a watering pi but need the clock to be correct for watering times.

Even when I freshly configure the localisation settings, it still is 2 hrs slow. so I have to manually set with:

sudo date -s 'Sun Sep 09 07:46:47 AEST 2018'

I even found a google sync I thought I could run in cron but it still gives it in utc

sudo date -s "$(curl -s --head http://google.com.au | grep ^Date: | sed 's/Date: //g')"

I have a pi hole set up, could that be doing it? Could this be a bug for my time zone? Can any Aussies on AEST confirm?

Alternatively I suppose I could just train my wife to convert to utc :)
Last edited by RPIWnivarna on Tue Sep 11, 2018 11:27 am, edited 1 time in total.

DirkS
Posts: 9840
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Time sync problem

Sat Sep 08, 2018 4:23 pm

If you're on Raspbian Stretch can you run

Code: Select all

timedatectl
systemctl status systemd-timesyncd.service
and post the output here.

RPIWnivarna
Posts: 7
Joined: Sun May 27, 2018 3:16 am
Location: Victoria, Australia

Re: Time sync problem

Mon Sep 10, 2018 6:17 am

Thanks for your help DirkS

timedatectl
Local time: Sun 2018-09-09 12:25:13 AEST
Universal time: Sun 2018-09-09 02:25:13 UTC
RTC time: n/a
Time zone: Australia/Melbourne (AEST, +1000)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no

● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
└─disable-with-time-daemon.conf
Active: active (running) since Sun 2018-09-09 12:20:24 AEST; 7min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 192 (systemd-timesyn)
Status: "Connecting to time server 178.63.9.212:123 (1.debian.pool.ntp.org)."
CGroup: /system.slice/systemd-timesyncd.service
└─192 /lib/systemd/systemd-timesyncd

Sep 09 12:24:54 squid systemd-timesyncd[192]: Timed out waiting for reply from 78.46.253.198:123 (2.debian.pool.ntp.org).
Sep 09 12:25:04 squid systemd-timesyncd[192]: Timed out waiting for reply from 193.141.27.1:123 (3.debian.pool.ntp.org).
Sep 09 12:25:14 squid systemd-timesyncd[192]: Timed out waiting for reply from 176.221.42.125:123 (3.debian.pool.ntp.org).
Sep 09 12:25:25 squid systemd-timesyncd[192]: Timed out waiting for reply from 131.188.3.220:123 (3.debian.pool.ntp.org).
Sep 09 12:25:35 squid systemd-timesyncd[192]: Timed out waiting for reply from 144.76.60.190:123 (3.debian.pool.ntp.org).
Sep 09 12:26:50 squid systemd-timesyncd[192]: Timed out waiting for reply from 212.18.3.19:123 (0.debian.pool.ntp.org).
Sep 09 12:27:00 squid systemd-timesyncd[192]: Timed out waiting for reply from 146.0.32.144:123 (0.debian.pool.ntp.org).
Sep 09 12:27:10 squid systemd-timesyncd[192]: Timed out waiting for reply from 144.76.76.107:123 (0.debian.pool.ntp.org).
Sep 09 12:27:20 squid systemd-timesyncd[192]: Timed out waiting for reply from 78.46.60.40:123 (0.debian.pool.ntp.org).
Sep 09 12:27:31 squid systemd-timesyncd[192]: Timed out waiting for reply from 213.172.105.106:123 (1.debian.pool.ntp.org).

PhatFil
Posts: 1226
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Time sync problem

Mon Sep 10, 2018 6:32 am

looks like your not establishing a connection with the ntp servers set so perhaps check for local reliable ntp servers and set accordingly.
https://raspberrypi.stackexchange.com/q ... ch-systems

RPIWnivarna
Posts: 7
Joined: Sun May 27, 2018 3:16 am
Location: Victoria, Australia

Re: Time sync problem

Mon Sep 10, 2018 9:57 am

Ok, took last suggestion and used googles ntp server

sudo nano /etc/systemd/timesyncd.conf

#NTP=216.239.35.0
FallbackNTP=0.arch.pool.ntp.org 1.arch.pool.ntp.org 2.arch.pool.ntp.org 3.arch.$
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048

● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
└─disable-with-time-daemon.conf
Active: active (running) since Sun 2018-09-09 15:39:58 AEST; 25min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 180 (systemd-timesyn)
Status: "Idle."
CGroup: /system.slice/systemd-timesyncd.service
└─180 /lib/systemd/systemd-timesyncd

Sep 09 16:03:22 squid systemd-timesyncd[180]: Timed out waiting for reply from 78.46.53.2:123 (1.arch.pool.ntp.org).
Sep 09 16:03:32 squid systemd-timesyncd[180]: Timed out waiting for reply from 85.10.240.253:123 (1.arch.pool.ntp.org).
Sep 09 16:03:43 squid systemd-timesyncd[180]: Timed out waiting for reply from 193.175.73.151:123 (2.arch.pool.ntp.org).
Sep 09 16:03:53 squid systemd-timesyncd[180]: Timed out waiting for reply from 213.202.247.29:123 (2.arch.pool.ntp.org).
Sep 09 16:04:03 squid systemd-timesyncd[180]: Timed out waiting for reply from 217.91.44.17:123 (2.arch.pool.ntp.org).
Sep 09 16:04:14 squid systemd-timesyncd[180]: Timed out waiting for reply from 78.46.204.247:123 (2.arch.pool.ntp.org).
Sep 09 16:04:24 squid systemd-timesyncd[180]: Timed out waiting for reply from 213.202.247.29:123 (3.arch.pool.ntp.org).
Sep 09 16:04:35 squid systemd-timesyncd[180]: Timed out waiting for reply from 185.11.138.90:123 (3.arch.pool.ntp.org).
Sep 09 16:04:45 squid systemd-timesyncd[180]: Timed out waiting for reply from 129.70.132.32:123 (3.arch.pool.ntp.org).
Sep 09 16:04:55 squid systemd-timesyncd[180]: Timed out waiting for reply from 94.16.116.137:123 (3.arch.pool.ntp.org).
[email protected]:~ $ timedatectl
Local time: Sun 2018-09-09 16:07:14 AEST
Universal time: Sun 2018-09-09 06:07:14 UTC
RTC time: n/a
Time zone: Australia/Melbourne (AEST, +1000)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no

So no progress.

DirkS
Posts: 9840
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Time sync problem

Mon Sep 10, 2018 10:33 am

Is there something in your network that blocks port 123?

RPIWnivarna
Posts: 7
Joined: Sun May 27, 2018 3:16 am
Location: Victoria, Australia

Re: Time sync problem

Tue Sep 11, 2018 12:40 am

Is there a reason pi hole would block port 123? I haven't touched the config of that, so it is all the default settings, I will disable it when I get home to test that one out.

RPIWnivarna
Posts: 7
Joined: Sun May 27, 2018 3:16 am
Location: Victoria, Australia

Re: Time sync problem

Tue Sep 11, 2018 6:29 am

Checked the admin interface:

Top Permitted Domains
Domain Hits Frequency
0.irobot.pool.ntp.org 473
1.irobot.pool.ntp.org 470
2.irobot.pool.ntp.org 460
3.irobot.pool.ntp.org 459
graph.facebook.com 189
www.google.com 136
query.yahooapis.com 132
2.debian.pool.ntp.org 131
3.debian.pool.ntp.org 117
android.clients.google.com 116

So it says it allows them through, will start pi with pihole disabled as test

[email protected]:~ $ timedatectl
Local time: Sun 2018-09-09 17:20:04 AEST
Universal time: Sun 2018-09-09 07:20:04 UTC
RTC time: n/a
Time zone: Australia/Melbourne (AEST, +1000)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
[email protected]:~ $ systemctl status systemd-timesyncd.service>output
Warning: systemd-timesyncd.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[email protected]:~ $ cat output
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
└─disable-with-time-daemon.conf
Active: active (running) since Sun 2018-09-09 17:17:10 AEST; 3min 12s ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 241 (systemd-timesyn)
Status: "Connecting to time server 46.163.88.237:123 (1.arch.pool.ntp.org)."
CGroup: /system.slice/systemd-timesyncd.service
└─241 /lib/systemd/systemd-timesyncd

Sep 09 17:18:42 squid systemd-timesyncd[241]: Timed out waiting for reply from 85.236.36.4:123 (3.debian.pool.ntp.org).
Sep 09 17:18:53 squid systemd-timesyncd[241]: Timed out waiting for reply from 78.47.226.109:123 (3.debian.pool.ntp.org).
Sep 09 17:19:03 squid systemd-timesyncd[241]: Timed out waiting for reply from 5.9.80.113:123 (3.debian.pool.ntp.org).
Sep 09 17:19:14 squid systemd-timesyncd[241]: Timed out waiting for reply from 193.141.27.1:123 (0.arch.pool.ntp.org).
Sep 09 17:19:24 squid systemd-timesyncd[241]: Timed out waiting for reply from 141.30.228.4:123 (0.arch.pool.ntp.org).
Sep 09 17:19:34 squid systemd-timesyncd[241]: Timed out waiting for reply from 185.233.106.45:123 (0.arch.pool.ntp.org).
Sep 09 17:19:44 squid systemd-timesyncd[241]: Timed out waiting for reply from 94.130.183.105:123 (0.arch.pool.ntp.org).
Sep 09 17:19:55 squid systemd-timesyncd[241]: Timed out waiting for reply from 138.68.126.106:123 (1.arch.pool.ntp.org).
Sep 09 17:20:05 squid systemd-timesyncd[241]: Timed out waiting for reply from 131.188.3.221:123 (1.arch.pool.ntp.org).
Sep 09 17:20:15 squid systemd-timesyncd[241]: Timed out waiting for reply from 165.227.159.15:123 (1.arch.pool.ntp.org).

Had to output to file, as it goes nuts as naked command for some reason

PhatFil
Posts: 1226
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Time sync problem

Tue Sep 11, 2018 6:46 am

just thinking aloud here but how sophisticated is your network router/adsl or cable modem has it got a NTP setting?? if so it might be 'smart' and expect you to point to it and not a remote server?

can you ping those ntp addys ?

one of the outputs lists time outs, is there a significant lag on your network connection ? would bumping up the timeouts have any impact?

epoch1970
Posts: 3045
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Time sync problem

Tue Sep 11, 2018 7:53 am

NTP is a separate protocol from HTTP, I suppose your setup blocks 123/udp which should be allowed in an out of the Pi and the router.
AFAIK you can install htpdate on the Pi. This package uses the server's HTTP header contents to set system time, so it should be compliant with your current setup. (Not all websites send back enough information, if you get no date back try to specify another site.)
The date obtained is less accurate than from NTP servers, but it should be "good enough".
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

RPIWnivarna
Posts: 7
Joined: Sun May 27, 2018 3:16 am
Location: Victoria, Australia

Re: Time sync problem

Tue Sep 11, 2018 11:25 am

And it is fixed.

[email protected]:~ $ date
Tue 11 Sep 14:06:21 AEST 2018
[email protected]:~ $ sudo apt install htpdate
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
htpdate
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 17.3 kB of archives.
After this operation, 53.2 kB of additional disk space will be used.
Get:1 http://raspbian.melbourneitmirror.net/raspbian stretch/main armhf htpdate armhf 1.1.3-2 [17.3 kB]
Fetched 17.3 kB in 2s (8,033 B/s)
Selecting previously unselected package htpdate.
(Reading database ... 40320 files and directories currently installed.)
Preparing to unpack .../htpdate_1.1.3-2_armhf.deb ...
Unpacking htpdate (1.1.3-2) ...
Setting up htpdate (1.1.3-2) ...
Processing triggers for systemd (232-25+deb9u4) ...
Processing triggers for man-db (2.7.6.1-2) ...
[email protected]:~ $ date
Tue 11 Sep 21:18:21 AEST 2018


Thank you epoch1970, that has instantly solved my problem that has been a thorn in my side for many months, I have already installed it on all my pis,

Thank you to all that have pitched in on this problem too.

PhatFil
Posts: 1226
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: (Solved) Time sync problem

Wed Sep 12, 2018 10:53 am

Glad to hear its sorted..

eAL
Posts: 3
Joined: Fri Aug 24, 2018 3:16 pm

Re: (Solved) Time sync problem

Wed Mar 27, 2019 11:59 am

Thanks guys this worked fine for me, too!
Struggeld also since september 2018 with this issue and used an RTC since, NO MORE!

Return to “Raspbian”