Nathan.Rivard
Posts: 37
Joined: Tue Sep 10, 2019 3:28 pm

Raspberry Pi 3B+ Unable to sync to correct time

Thu Oct 03, 2019 4:32 pm

I am attempting to get my raspberry pi to set the time in accordance with a time zone. I have already set the time zone as being relative to the Chicago timezone and it still does not sync correctly with CST. I have also been using the manual input for setting time which works for a bit, until the pi crashes, which it does at least once a day. Then, when I turn it back on, the pi's time is hilariously off. Is there any way to force the pi to sync to the correct time?

Crowbot
Posts: 24
Joined: Sat Jul 13, 2019 2:03 pm
Location: NYC

Re: Raspberry Pi 3B+ Unable to sync to correct time

Thu Oct 03, 2019 4:57 pm

Usually the Pi will sync up when it's online. Are you online? Also, I'd want to know why the Pi crashes so reliably.

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

Re: Raspberry Pi 3B+ Unable to sync to correct time

Thu Oct 03, 2019 5:00 pm

Nathan.Rivard wrote:
Thu Oct 03, 2019 4:32 pm
I have already set the time zone as being relative to the Chicago timezone
What do you mean by this exactly? Normally you set a timezone relative to UTC.
How exactly did you change the timezone?
What is the difference the time the Pi shows and what you expect it to be?
What is the output of

Code: Select all

timedatectl
?

Nathan.Rivard
Posts: 37
Joined: Tue Sep 10, 2019 3:28 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Thu Oct 03, 2019 8:39 pm

Yes, the unit is online and in system-config I set the time in the same timezone as Chicago time
timedatectl:

Code: Select all

Local time: Thu 2019-10-03 06:34:24 CDT
           Universal time: Thu 2019-10-03 11:34:24 UTC
                 RTC time: n/a
                Time zone: America/Chicago (CDT, -0500)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no
I would like to add that the actual time and date are 10/3/2019 at 3:39 PM

Andyroo

Re: Raspberry Pi 3B+ Unable to sync to correct time

Thu Oct 03, 2019 8:54 pm

Does your Pi have internet connection correctly set up?
What happens if you

Code: Select all

ping 8.8.8.8
ping google.com

Nathan.Rivard
Posts: 37
Joined: Tue Sep 10, 2019 3:28 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Mon Oct 07, 2019 4:03 pm

Andyroo wrote:
Thu Oct 03, 2019 8:54 pm
Does your Pi have internet connection correctly set up?
What happens if you

Code: Select all

ping 8.8.8.8
ping google.com
When I do that I get

Code: Select all

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
102 packets transmitted, 0 received, 100% packet loss, time 124ms
The google doesn't really do much for a while

knute
Posts: 500
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: Raspberry Pi 3B+ Unable to sync to correct time

Mon Oct 07, 2019 8:13 pm

It looks like a DNS problem. The output from timedatectl shows not synced. No return from the google.com ping. All symptoms of DNS not working correctly.

You might post the last 15 or so lines of /etc/dhcpcd.conf if you are using a static IP.

If you are using dhcp then: cat /var/run/dnsmasq/resolv.conf.

Or maybe you aren't on line at all?

User avatar
lpsw
Posts: 191
Joined: Thu Jun 25, 2015 4:45 pm
Location: USA

Re: Raspberry Pi 3B+ Unable to sync to correct time

Mon Oct 07, 2019 8:28 pm

knute wrote:
Mon Oct 07, 2019 8:13 pm
It looks like a DNS problem. The output from timedatectl shows not synced. No return from the google.com ping. All symptoms of DNS not working correctly.

You might post the last 15 or so lines of /etc/dhcpcd.conf if you are using a static IP.

If you are using dhcp then: cat /var/run/dnsmasq/resolv.conf.

Or maybe you aren't on line at all?
If a ping to 8.8.8.8 fails, it's clear there is no functional connection to the internet.
Self-education is, I firmly believe, the only kind of education there is - Isaac Asimov

Nathan.Rivard
Posts: 37
Joined: Tue Sep 10, 2019 3:28 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Tue Oct 08, 2019 2:38 pm

lpsw wrote:[/code]ime=1570480122 user_id=152029]
knute wrote:
Mon Oct 07, 2019 8:13 pm
It looks like a DNS problem. The output from timedatectl shows not synced. No return from the google.com ping. All symptoms of DNS not working correctly.

You might post the last 15 or so lines of /etc/dhcpcd.conf if you are using a static IP.

If you are using dhcp then: cat /var/run/dnsmasq/resolv.conf.

Or maybe you aren't on line at all?
If a ping to 8.8.8.8 fails, it's clear there is no functional connection to the internet.
I am able to connect to google/anything on the web browser as well as transfer files to a remote computer on the VNC Server. The last 15 lines of the /etc/dhcpcd.conf are

Code: Select all

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0

pcmanbob
Posts: 7935
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi 3B+ Unable to sync to correct time

Tue Oct 08, 2019 4:02 pm

What happens if you try running this from command line ?

Code: Select all

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
does it set the correct time and date for you ?
and does the pi then keep the correct time and date ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Nathan.Rivard
Posts: 37
Joined: Tue Sep 10, 2019 3:28 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Tue Oct 08, 2019 4:45 pm

pcmanbob wrote:
Tue Oct 08, 2019 4:02 pm
What happens if you try running this from command line ?

Code: Select all

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
does it set the correct time and date for you ?
and does the pi then keep the correct time and date ?
Well that worked perfectly thank you so much

Nathan.Rivard
Posts: 37
Joined: Tue Sep 10, 2019 3:28 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Tue Oct 08, 2019 8:00 pm

Nathan.Rivard wrote:
Tue Oct 08, 2019 4:45 pm
pcmanbob wrote:
Tue Oct 08, 2019 4:02 pm
What happens if you try running this from command line ?

Code: Select all

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
does it set the correct time and date for you ?
and does the pi then keep the correct time and date ?
Well that worked perfectly thank you so much
I was wrong, it worked until the pi crashed while running a python program for a few hours. It is now 20 min behind

pcmanbob
Posts: 7935
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi 3B+ Unable to sync to correct time

Tue Oct 08, 2019 9:17 pm

So your pi is still not syncing it's time with internet time.

So is this a new build on the SD card or a long running version of the OS ?

And which OS are you running ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
lpsw
Posts: 191
Joined: Thu Jun 25, 2015 4:45 pm
Location: USA

Re: Raspberry Pi 3B+ Unable to sync to correct time

Tue Oct 08, 2019 9:51 pm

Can you successfully ping to 8.8.8.8?
Self-education is, I firmly believe, the only kind of education there is - Isaac Asimov

pcmanbob
Posts: 7935
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi 3B+ Unable to sync to correct time

Tue Oct 08, 2019 9:56 pm

lpsw wrote:
Tue Oct 08, 2019 9:51 pm
Can you successfully ping to 8.8.8.8?
Seeing the OP was able to set the time with the command I suggested which used Google to get the current time I would think the pi has a working internet connection.

OP has also stated that web can be browsed via chrome successfully.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
lpsw
Posts: 191
Joined: Thu Jun 25, 2015 4:45 pm
Location: USA

Re: Raspberry Pi 3B+ Unable to sync to correct time

Wed Oct 09, 2019 12:28 am

There was also this
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
102 packets transmitted, 0 received, 100% packet loss, time 124ms
Self-education is, I firmly believe, the only kind of education there is - Isaac Asimov

pcmanbob
Posts: 7935
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspberry Pi 3B+ Unable to sync to correct time

Wed Oct 09, 2019 11:16 am

lpsw wrote:
Wed Oct 09, 2019 12:28 am
There was also this
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
102 packets transmitted, 0 received, 100% packet loss, time 124ms
Yes the information provided by the OP is very confusing , says the ping 8.8.8.8 does not work yet he can surf the web and the command to set the time using information from google.com works.

Both answers cant be true !!
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
DougieLawson
Posts: 37073
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Raspberry Pi 3B+ Unable to sync to correct time

Wed Oct 09, 2019 6:12 pm

pcmanbob wrote:
Wed Oct 09, 2019 11:16 am


Yes the information provided by the OP is very confusing , says the ping 8.8.8.8 does not work yet he can surf the web and the command to set the time using information from google.com works.

Both answers cant be true !!
They may not be mutually exclusive if there's a firewall blocking ICMP/IP.

If the same firewall blocks UDP/IP that could also explain why time synchronisation doesn't work.

The OP needs to ask the folks that own the network.

htpdate may be an answer as it pulls the time from Google's home page or from Wikipedia.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

polygaryd
Posts: 6
Joined: Sun Jan 29, 2017 5:02 am

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 03, 2020 6:22 am

Hi guys, i have been having the same issue with the time not syncing on my pi 3b+ running retropie with stretch kernel.

I have called my isp and asked if they are blocking udp 123 after turning off my routers firewall and the time still wouldnt sync.

When i used lxde or kodi the clock is off by 7 hours. So its 11:01pm right now and the clock says 4:21am mst. Im in Phoenix az my time zone is correct from entering it rasp-pi config from retropie menu.

When i type timedatectl it shows
Local time is thu 2020-01-02 4:21:51 mst
Universal time is thu 2020-01-02 11:21:51 UTC
Rtc : n/a
Time zone us/arizona (mst, - 0700)
Network time on : yes (still doesnt work set to no)
Ntp synced : yes
Rtc in local tz: no

I set the time manually and it stays till i shut the pi down.

Ive tried the htpdate which works but i assume only when i go into lxde and open a browser. So thats not ideal as I mainly use retropie for games and kodi, lxde is a backup to access files and research a pi specific issue as i can have chrome and terminal open at the same time to run commands for testing.

I can ping 8.8.8.8 and google.com just fine
I can ping any of the ip addresses when you try to stop ntp and then do ntpd - q - g then restart ntp. All that does is scroll through a ton of ip addresses never ending till you crtl c out of it back to terminal prompt.

Ntpq - p has no stats in it for when reach delay offset jitter columns

Ntptime says estimated error is 16 micro seconds and everything looks normal on there. I can provide screen shots if necessary.

I added the /sbin/iptables line in rc.Local saved and rebooted. Same deal time is 7 hours earlier in the day.

What am i missing here? Bad pi? None of my other devices which are non pi units btw have this issue. Be it a windows/linux desktop (ethernet connected), windows/linux/mac/Android x86 slate, Android tablets 4.4.4 and 7.1,
Android phones with 7.0 and 6.1. As you can see i have a very wide variety of devices running a very diverse set of operation system types and versions.

Only device with this issue is the pi 3b+. Its driving me absolutely nuts that i cant figure this out.

User avatar
DougieLawson
Posts: 37073
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 03, 2020 9:08 am

If you want to run plain old ntpd you MUST run sudo systemctl disable systemd-timesyncd.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

polygaryd
Posts: 6
Joined: Sun Jan 29, 2017 5:02 am

Re: Raspberry Pi 3B+ Unable to sync to correct time

Sat Jan 04, 2020 4:09 am

Is that what the issue is? Timesynced and ntpd are conflicting?

beta-tester
Posts: 1331
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Raspberry Pi 3B+ Unable to sync to correct time

Sat Jan 04, 2020 6:35 am

DougieLawson wrote:
Fri Jan 03, 2020 9:08 am
If you want to run plain old ntpd you MUST run sudo systemctl disable systemd-timesyncd.

this should be done automatically by the default start conditions of systems-timesyncd
(depending what ntp service you are running/if it is listed in the start conditions)
but, yes, disabling the service manually is more intuitive.

Code: Select all

$ cat /lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf 
[Unit]
# don't run timesyncd if we have another NTP daemon installed
ConditionFileIsExecutable=!/usr/sbin/ntpd
ConditionFileIsExecutable=!/usr/sbin/openntpd
ConditionFileIsExecutable=!/usr/sbin/chronyd
ConditionFileIsExecutable=!/usr/sbin/VBoxService

Code: Select all

$ sudo systemctl status systemd-timesyncd.service
Warning: The unit file, source configuration file or drop-ins of systemd-timesyncd.service changed on disk. Run 'systemctl daemon-reload' to reload units.
? 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: inactive (dead)
Condition: start condition failed at ...
           ?? ConditionFileIsExecutable=!/usr/sbin/... was not met
     Docs: man:systemd-timesyncd.service(8)

... Server systemd[1]: Condition check resulted in Network Time Synchronization being skipped.
... Server systemd[1]: Condition check resulted in Network Time Synchronization being skipped.
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

beta-tester
Posts: 1331
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Raspberry Pi 3B+ Unable to sync to correct time

Sat Jan 04, 2020 7:02 am

polygaryd wrote:
Fri Jan 03, 2020 6:22 am
Hi guys, i have been having the same issue with the time not syncing on my pi 3b+ running retropie with stretch kernel.

I can ping any of the ip addresses when you try to stop ntp and then do ntpd - q - g then restart ntp. All that does is scroll through a ton of ip addresses never ending till you crtl c out of it back to terminal prompt.

Ntpq - p has no stats in it for when reach delay offset jitter columns

Ntptime says estimated error is 16 micro seconds and everything looks normal on there. I can provide screen shots if necessary.

What am i missing here? Bad pi? None of my other devices which are non pi units btw have this issue.
Only device with this issue is the pi 3b+. Its driving me absolutely nuts that i cant figure this out.
  • i don't beleave your RPi is broken, otherwise the manual adjusted time would drifting alot during opperating.
  • did you installed ntpd manually?
  • was there another ntp service installed parallel like chrony?
    i can't remember if chrony was default ntp service under raspbian stretch.
  • is the time difference of 7h static - maybe you haven't set you timezone correctly (sudo raspi-config).
  • if ntpd/chrony is running, is that service configured to change/manage the system time or only serve ntp time to clients?
  • install an official actual raspbian buster without modification except configuring the timezone (sudo raspi-config), and see if the issue still exist
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

polygaryd
Posts: 6
Joined: Sun Jan 29, 2017 5:02 am

Re: Raspberry Pi 3B+ Unable to sync to correct time

Sat Jan 04, 2020 7:11 am

I just want a time service to sync automatically when the pi is connected to my wifi network with internet. I believe i have been reading that timesyncd has superceded ntpq or ntpd worth stretch kernel correct? Not sure if ntpq and ntpd are part of the same software pack or not yet. Very confusing.
So id like to use the built in time date syncing service. What should i do? Remove ntpd/ntpq? Is having ntpd/ntpq installed conflicting with timesyncd?
The time syncing service wasnt working before i messed with it on a clean retropie stretch build. So i want to get back to square one and use the built in time service and then make it work. Unless the issue is the built in time service and i need to disable timesyncd and use ntpd/ntpq. Please advise. Im lost in all of this.

beta-tester
Posts: 1331
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Raspberry Pi 3B+ Unable to sync to correct time

Sat Jan 04, 2020 7:33 am

first i would take a look what services are active:

Code: Select all

# should be active by default
sudo systemctl status --no-pager systemd-timesyncd;
sudo systemctl status --no-pager fake-hwclock;

# should be not there or inactive by default
sudo systemctl status --no-pager chrony* | grep Active;
sudo systemctl status --no-pager ntp* | grep Active;
sudo systemctl status --no-pager openntp* | grep Active;
if systemd-timesyncd isn't Active but chrony*, ntp* or openntp* are active, you can try to stop and disable them

Code: Select all

sudo systemctl stop chrony*;
sudo systemctl disable chrony;
sudo systemctl stop ntp*;
sudo systemctl disable ntp;
sudo systemctl stop openntp*;
sudo systemctl disable openntpd;
and enable and restart the normal systemd-timesyncd service

Code: Select all

sudo systemctl enable systemd-timesyncd;
sudo systemctl restart systemd-timesyncd;
if it works now and chrony or ntpd was active previously, you can decide to uninstall them.

Code: Select all

sudo apt purge --auto-remove chrony ntp openntpd;
Last edited by beta-tester on Fri Jan 10, 2020 6:09 am, edited 2 times in total.
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

Return to “Troubleshooting”