Page 1 of 1

Raspberry Pi 3B+ Unable to sync to correct time

Posted: Thu Oct 03, 2019 4:32 pm
by Nathan.Rivard
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?

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

Posted: Thu Oct 03, 2019 4:57 pm
by Crowbot
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.

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

Posted: Thu Oct 03, 2019 5:00 pm
by DirkS
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
?

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

Posted: Thu Oct 03, 2019 8:39 pm
by Nathan.Rivard
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

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

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

Code: Select all

ping 8.8.8.8
ping google.com

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

Posted: Mon Oct 07, 2019 4:03 pm
by Nathan.Rivard
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

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

Posted: Mon Oct 07, 2019 8:13 pm
by knute
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?

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

Posted: Mon Oct 07, 2019 8:28 pm
by lpsw
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.

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

Posted: Tue Oct 08, 2019 2:38 pm
by Nathan.Rivard
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

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

Posted: Tue Oct 08, 2019 4:02 pm
by pcmanbob
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 ?

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

Posted: Tue Oct 08, 2019 4:45 pm
by Nathan.Rivard
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

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

Posted: Tue Oct 08, 2019 8:00 pm
by Nathan.Rivard
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

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

Posted: Tue Oct 08, 2019 9:17 pm
by pcmanbob
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 ?

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

Posted: Tue Oct 08, 2019 9:51 pm
by lpsw
Can you successfully ping to 8.8.8.8?

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

Posted: Tue Oct 08, 2019 9:56 pm
by pcmanbob
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.

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

Posted: Wed Oct 09, 2019 12:28 am
by lpsw
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

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

Posted: Wed Oct 09, 2019 11:16 am
by pcmanbob
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 !!

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

Posted: Wed Oct 09, 2019 6:12 pm
by DougieLawson
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.