NTP Not Updating Automatically
-
- Top Contributor
- Posts: 1323
- Joined: Thu Jun 11, 2020 2:31 am
- Has thanked: 15 times
- Been thanked: 213 times
Re: NTP Not Updating Automatically
- jlancaster86
- Posts: 148
- Joined: Sat Jun 27, 2020 1:33 pm
- Has thanked: 130 times
- Been thanked: 35 times
Re: NTP Not Updating Automatically
At startup, the settings in /etc/ntp.conf are used:
Code: Select all
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst
# Allow only time queries, at a limited rate, sending KoD when in excess.
# Allow all local queries (IPv4, IPv6)
restrict default nomodify nopeer noquery limited kod
restrict 127.0.0.1
restrict [::1]
Code: Select all
server 192.168.54.254 iburst
# Allow only time queries, at a limited rate, sending KoD when in excess.
# Allow all local queries (IPv4, IPv6)
restrict default nomodify nopeer noquery limited kod
restrict 127.0.0.1
restrict [::1]
- jlancaster86
- Posts: 148
- Joined: Sat Jun 27, 2020 1:33 pm
- Has thanked: 130 times
- Been thanked: 35 times
Re: NTP Not Updating Automatically
For now, I've tweaked my ntp.sh script to have it update the time a bit faster at startup. Now, instead of waiting 10 seconds befor trying to update, it will try immediately and retry up to 20 times with a 1-second pause between each attempt:
Code: Select all
#!/bin/bash
NTP_SERVER="0.pool.ntp.org"
i=0
while [ $i -lt 20 ]
do
if ! ntpdate -bsu $NTP_SERVER
then
if $i == 19
then
echo echo "Unable to sync after 20 attempts."
fi
sleep 1s
((i++))
else
echo "Date and time is:"
echo "$(date)"
i=20
fi
done
-
- Top Contributor
- Posts: 623
- Joined: Fri Jan 22, 2021 4:36 pm
- Has thanked: 80 times
- Been thanked: 324 times
Re: NTP Not Updating Automatically
At this point the MiSTer boot process doesn't wait for proper network connectivity to perform this action. It should do that to fix the behavior that people expect.
A much more resilient way would be to run an NTP daemon like Chrony in the background. It's tiny and won't affect the rest of the system in a noticeable way. Chrony can be told to do big leaps whenever needed, so it won't have to wait for connectivity.
Sleeping some amount of time before firing up ntpdate is not a real solution either. Sure it works sometimes because you're usually more likely to have connectivity later, but nothing actually guaratees that at all so the failure mode is still there.
Re: NTP Not Updating Automatically
I also replaced the servers with my router's IP address, and it also works for me. Thanks for the idea.jlancaster86 wrote: ↑Fri Jan 28, 2022 11:25 pm If I replace those four servers with my MikroTik router's IP address, it works just fine:
Re: NTP Not Updating Automatically
I checked my /var/log/messages file and it seems like there are a bunch of stack traces from my wireless adapter, so I'm assuming it just takes longer to connect now because of that.
Re: NTP Not Updating Automatically
Do we have a solucion to this yet? I have this exact problem, the date and date does not show up at startup and my MiSTer internet is fine. It worked before, the updates maybe messed up the things here. A brand new up to date installation does not fix this.
-
- Scripting Wizard
- Posts: 106
- Joined: Sun May 24, 2020 8:20 pm
- Been thanked: 41 times
Re: NTP Not Updating Automatically
As a mitigation, the updater launchers now try to ntpdate if they see that date command is off. If you use downloader, reinstall the launcher to get this new version.
But this is no definitive solution and won't fix other clock usage problems in cores if you don't run any updater after booting or you don't have an internet connection. A better solution would be installing RTC add-on board, as it keeps the clock without depending on the network.
- thisisamigaspeaking
- Posts: 244
- Joined: Mon May 23, 2022 12:28 am
- Has thanked: 80 times
- Been thanked: 23 times
Re: NTP Not Updating Automatically
My router even has an NTPd, not sure how many do.
mightor wrote: ↑Fri Jan 28, 2022 3:07 pmSo the problem may have been introduced in the latest Linux versions. Keeping old Linux version is not an option as modern cores needs up to date Linux version. So while waiting for a fix, there are only two ways to get date/time at each boot: by manually running rtc.sh or by using your automated method to run a ntp.sh script at boot time.
jlancaster86 wrote: ↑Fri Jan 28, 2022 2:28 pmYeah, I just tried rolling back to menu_20210315.rbf, and the clock isn't updating. Looks like it's something in the Linux installation.
How many people are currently having this issue?
-
- Top Contributor
- Posts: 623
- Joined: Fri Jan 22, 2021 4:36 pm
- Has thanked: 80 times
- Been thanked: 324 times
Re: NTP Not Updating Automatically
I guess I wasn't very clear in my original comment. Your router's DHCP service can set an NTP server as a DHCP option, which it will then pass down to the connecting clients. If it does that, a client has a hint as to which NTP server to sync from. If your router has its own NTP service on board, it's quite likely that it passes this option through its DHCP service as well. To close the gap, the client must actually make use of the information it gets handed from DHCP. If it doesn't do that, it's still useless.. but you could manually configure ntp to sync to the router's private IP address (the default gateway IP).
-
- Top Contributor
- Posts: 860
- Joined: Wed Feb 09, 2022 11:50 pm
- Has thanked: 64 times
- Been thanked: 195 times
Re: NTP Not Updating Automatically
The Mister is using ntpd, which AFAIK pays no attention to DHCP whatever. It uses /etc/ntp.conf for configuration. In there are four lines for using pool.ntp.org servers.
If time isn't syncing, dropping to a command line, typing "ntpq", and typing "peers" will tell you a lot about the state of the daemon. If you need help interpreting, you can post that output here
Note that because it's going to pool.ntp.org by name, DNS needs to be working.
Re: NTP Not Updating Automatically
Tried to mess with the NTP settings on my router (Asus RT-AX88U) as a last resort but no dice. Maybe Sorgelig will take a look into this.
-
- Top Contributor
- Posts: 1323
- Joined: Thu Jun 11, 2020 2:31 am
- Has thanked: 15 times
- Been thanked: 213 times
Re: NTP Not Updating Automatically
One other completely random idea - you don't happen to have two MiSTers on the network at the same time, do you? By default, they all share one MAC address, which can be extremely disruptive to communications as a whole.
Re: NTP Not Updating Automatically
Nop, just one. A friend has the same issue and others on this forum also, surely this is not an isolated case.
-
- Top Contributor
- Posts: 860
- Joined: Wed Feb 09, 2022 11:50 pm
- Has thanked: 64 times
- Been thanked: 195 times
Re: NTP Not Updating Automatically
What does your /etc/ntp.conf look like?
I'm also running a local NTP server, but I was doing that originally, so if there's a problem syncing to outside servers, I wouldn't have seen it.
edit with a random thought: if your Mister can talk to your local network but can't get outside, make sure it's getting a default route from the DHCP server. Without a default route, a machine can't leave the local network. You can check with route -n:
Code: Select all
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 A.B.C.1 0.0.0.0 UG 0 0 0 eth0
A.B.C.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
That's saying that for any global address, forward to the address A.B.C.1. (usually routers are on .1, although they don't have to be.) I believe UG means Up, Gateway. (the default route.)
Then, for every IP address from A.B.C.0 to A.B.C.255, they're connected to the Ethernet port named eth0. Any machine with one of those IPs is on the same wire, and can be spoken to directly.
If you don't have the first line, then the machine can only talk to other machines on the same wire. If you don't have the second line, the machine can't talk to anything.
If you have three or more lines, you probably have a WiFi card connected and active at the same time as Ethernet. This is almost always a bad idea, unless you understand networking well enough to make it work properly.
Also make sure your /etc/resolv.conf says something sane. It should look at least like this:
Code: Select all
domain example.com
nameserver 8.8.8.8
The domain should be whatever you use locally. Nameserver can be any number with a valid DNS resolver. 8.8.8.8 is Google. 9.9.9.9 is Plan 9. I think they also run 1.1.1.1 as a nameserver. Any of those numbers should work unless your ISP is blocking them. Some do, because they want to snoop on your DNS queries.
The number could also be your router, at A.B.C.1. This is typically fine, as long as the router is working. Using all 8s or all 9s may be more reliable.
Re: NTP Not Updating Automatically
I'm going to have to spend some time on this as well. The last Linux update borked my MiSTer and now I can't run any of the scripts due to no NTP.
-
- Top Contributor
- Posts: 1911
- Joined: Wed May 27, 2020 1:59 pm
- Has thanked: 145 times
- Been thanked: 454 times
Re: NTP Not Updating Automatically
Use Putty to ssh into your MISTer, go to the Scripts directory, run the rtc.sh script, even if you do not have a RTC, it will update your Linux Date and Time. You can also run update_all.sh after that.