Nathan.Rivard
Posts: 36
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: 10018
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: 36
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: 36
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: 477
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: 168
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: 36
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: 7306
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: 36
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: 36
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: 7306
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: 168
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: 7306
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: 168
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: 7306
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: 36578
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.

Return to “Troubleshooting”