Bosse_B
Posts: 967
Joined: Thu Jan 30, 2014 9:53 am

Network time sync on Raspbian Buster???

Fri Nov 08, 2019 4:28 pm

I have a difficult time getting my RPi4 with an updated Buster to time sync to the network...
I have googled and found numerous commands, none of which works on my system.

These do not even exist:
ntptime
ntpq

And if I use timedatectl it still does not work even though it exists:

Code: Select all

$ sudo timedatectl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to create bus connection: Host is down
None of the threads and pages where this command is mentioned talks about this issue...

My network time setting question is related to a discussion on the use of DS3231 RTC modules, but this is so specific I put it into this separate thread.

What I have done in summary is:
- Enabled I2C in raspi-config
- edited /boot/config.txt and added this at the end of the first section:

Code: Select all

dtoverlay=i2c-rtc,ds3231
- Shut down and plugged in a DS3231 RTC module
- Started up again
Now the time of my RPi4 is off by 42 seconds (probably from the RTC unit I have not used for a couple of years).

The advice I have read on this is:
- Do a network time sync
- Write the time to the RTC device

But how to do the network sync is not described....

Seems like something that exists in Raspbian itself without having to install extra software, after all without having the RTC module present Raspbian updated to network time just fine...
Bo Berglund
Sweden

bls
Posts: 597
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Network time sync on Raspbian Buster???

Fri Nov 08, 2019 6:06 pm

I used ntp (sudo apt-get install ntp) for a long time, but have recently switched to chrony (sudo apt-get install chrony). Both work fine, but I'm sticking with chrony for now. chrony needs a little config file. Here's how I generate mine. 192.168.16.0 and 10.16.10.0 are subnets on my network; adjust for yours as appropriate.

Code: Select all

sudo cat >> /etc/chrony/chrony.conf <<EOF
allow 192.168.16.0/24
allow 10.16.10.0/24
EOF
Super-useful tools:
RPi SD Card Image Manager: https://github.com/gitbls/sdm
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo
Easy-Peasy VPN installer/manager: https://github.com/gitbls/pistrong

Paul Hutch
Posts: 538
Joined: Fri Aug 25, 2017 2:58 pm
Location: Blackstone River Valley, MA, USA
Contact: Website

Re: Network time sync on Raspbian Buster???

Fri Nov 08, 2019 6:58 pm

Bosse_B wrote:
Fri Nov 08, 2019 4:28 pm
<snip>

And if I use timedatectl it still does not work even though it exists:

Code: Select all

$ sudo timedatectl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to create bus connection: Host is down
<snip>
The problem appears to be that somehow sytemd has been disabled on your Pi, if you can get systemd working as the init system then timedatectl will run at startup and do NTP sync for you.

hippy
Posts: 7459
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Network time sync on Raspbian Buster???

Fri Nov 08, 2019 6:58 pm

Code: Select all

sudo timedatectl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to create bus connection: Host is down
There's something odd going on there. Works for me using stock Buster with Desktop ...

Code: Select all

pi@Pi3B:~ $ timedatectl
               Local time: Fri 2019-11-08 18:58:04 GMT
           Universal time: Fri 2019-11-08 18:58:04 UTC
                 RTC time: n/a
                Time zone: Europe/London (GMT, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Bosse_B
Posts: 967
Joined: Thu Jan 30, 2014 9:53 am

Re: Network time sync on Raspbian Buster???

Fri Nov 08, 2019 7:25 pm

Yes, odd is an understatement!
This system worked fine until this morning when I enabled I2C using raspi-config in order to prepare for the RTC module.
I have not used the desktop since a few days when I worked on designing the add-on board I am preparing for use with the RPi.
It contains basically these items:
- A HAT ID EEPROM
- The DS3231M RTC chip
- A level converter from digital serial comm to RS232
- Two relays with FET drivers hooked to GPIO pins

After laying out the board in my CAD system I went into prototyping mode and intended to check how the RTC could be activated on the target system (Buster).
I had already a number of years ago bought this module and used it on a RPi2B+ device, which has been running happily (no desktop installed) ever since.
So now I stole this in order to use it on my dev system.
And then while fixing the configurations for the RTC my desktop got hosed...
Did not notice at first since I usually use PuTTY command line for my Pi's...

What I need now is figuring out which config files or scripts are possibly involved with starting up the GUI so I can look at them.
And I have now removed the RTC module and reverted the config file edits I did along the way...
Bo Berglund
Sweden

Bosse_B
Posts: 967
Joined: Thu Jan 30, 2014 9:53 am

Re: Network time sync on Raspbian Buster???

Fri Nov 08, 2019 7:29 pm

bls wrote:
Fri Nov 08, 2019 6:06 pm
I used ntp (sudo apt-get install ntp) for a long time, but have recently switched to chrony (sudo apt-get install chrony). Both work fine, but I'm sticking with chrony for now. chrony needs a little config file. Here's how I generate mine. 192.168.16.0 and 10.16.10.0 are subnets on my network; adjust for yours as appropriate.

Code: Select all

sudo cat >> /etc/chrony/chrony.conf <<EOF
allow 192.168.16.0/24
allow 10.16.10.0/24
EOF
What use are the allow lines?
Is chrony implementing a time server for the local network and so this defines who is allowed to ask?
After editing the file, do I have to start/restart chrony?
If so how does the command line look like for that?
Bo Berglund
Sweden

bls
Posts: 597
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Network time sync on Raspbian Buster???

Fri Nov 08, 2019 8:42 pm

Bosse_B wrote:
Fri Nov 08, 2019 7:29 pm
bls wrote:
Fri Nov 08, 2019 6:06 pm
I used ntp (sudo apt-get install ntp) for a long time, but have recently switched to chrony (sudo apt-get install chrony). Both work fine, but I'm sticking with chrony for now. chrony needs a little config file. Here's how I generate mine. 192.168.16.0 and 10.16.10.0 are subnets on my network; adjust for yours as appropriate.

Code: Select all

sudo cat >> /etc/chrony/chrony.conf <<EOF
allow 192.168.16.0/24
allow 10.16.10.0/24
EOF
What use are the allow lines?
Is chrony implementing a time server for the local network and so this defines who is allowed to ask?
After editing the file, do I have to start/restart chrony?
If so how does the command line look like for that?
Correct. Chrony can be a time server for the local network. I should have been more clear. And complete. :oops:

Full story: 'sudo apt-get install chrony' installs a client only. If that's what you want, you're done. If you want chrony to be a server sudo edit /etc/chrony/chrony.conf with your editor and add two lines:

Code: Select all

bindaddress <your local ip>
allow
Then restart chrony with sudo systemctl restart chrony
Super-useful tools:
RPi SD Card Image Manager: https://github.com/gitbls/sdm
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo
Easy-Peasy VPN installer/manager: https://github.com/gitbls/pistrong

alphanumeric
Posts: 2528
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Network time sync on Raspbian Buster???

Fri Nov 08, 2019 8:44 pm

If it was me, at this point I think I would go back to a stock install of Buster. IMHO It's the sure fire way to undo what ever went wrong. I'm thinking a typo was made at some point that did something, but not the something you wanted it to do?

jj_0
Posts: 113
Joined: Wed Jul 11, 2012 7:07 am

Re: Network time sync on Raspbian Buster???

Fri Nov 08, 2019 8:53 pm

What does

Code: Select all

systemctl status timedatectl
say?

Return to “General discussion”