Fix Date and time

If you would like to try it, we are testing a workaround that should work for most (probably all) people having problems with the time not being set properly. To manually install the update download and install the correct version for your device:

Pi1:

wget http://46.37.189.135/osmc/apt/pool/main/a/armv6l-network-osmc/armv6l-network-osmc_1.4.5_armhf.deb
sudo dpkg -i armv6l-network-osmc_1.4.5_armhf.deb

Pi 2 / Vero:

wget http://46.37.189.135/osmc/apt/pool/main/a/armv7-network-osmc/armv7-network-osmc_1.4.5_armhf.deb
sudo dpkg -i armv7-network-osmc_1.4.5_armhf.deb

Please let us know if this helps fix the time/date not being set on boot.

For some technical background on this for those interested, the problem is not actually a bug in our ntp client, but rather source port 123 (used by the ntp protocol) being blocked by the router/ISP.

So we are implementing a workaround very similar to that used in Raspbmc - during boot the time is first set approximately by sending an HTTP query to google/apple/microsoft and using the Date field in the returned HTTP header. This is only accurate to within about a second or two allowing for network delays, but is better than being out by 40 years… :smile:

After that ntpd is started and will set the time more accurately and make fine adjustments to keep the time within a few milliseconds. So if you cant use ntp because port 123 is blocked your time won’t be as accurate and won’t be continually fine tuned to stay in sync but it will be near enough. If you can use ntp (your date/time currently works ok) there is no down side - your time will stay accurately synced to ntp time.

This should be part of the next major round of updates.

Sorry for the delay. I missed this question being posted until now. I have dsl and I’m using the dsl modem/router (BEC brand) that was provided. I also have a small network switch between the Vero and the router. Yes the Vero is on a private and reserved IP address.

I will try the update when I get a chance and report back what happens.

I installed the update but I can’t tell if it has helped or not since my time and date has been correct since the manual update.

Try shutting down for 5 minutes then booting up.

If it’s working the time will be correct, if it’s not working the time will be 5 minutes behind.

That makes sense. I will try that.

My time appears to be updating correctly now. I unplugged it for a while and it is still correct after booting back up.

The new updates worked! I had given up on OSMC gone back to Raspmc and thought I would try it one more time. I read all your posts and after much trial and error (might have been the new updates today), voila! the time and date worked perfectly. I am going to copy this SD card to another to make sure I have a clone, just in case.

Thanks for all the help and for working so hard to make OSMC such a great success.

Glad to hear it. We pushed out a load of updates for RC3 today including a fix for setting the time so yes if you run updates the time fix should be installed.

Note that this fix is technically more of a workaround - if ntp is not able to connect then the time is only set once during boot using an HTTP request - this time may be anywhere up to about a second behind, (typically about 0.2 to 0.8 seconds behind I’ve measured) and will gradually drift out of time by as much as a few seconds per day (due to the accuracy of the Pi clock) unless you reboot as the time is not being periodically corrected.

However - this is more or less the exact same workaround that was used in Raspbmc, so you are no worse off than you were in Raspbmc. (We had forgotten that workaround existed in Raspbmc so have re-implemented it in OSMC as apparently a few people were relying on it)

To get much more precise time (within 0.1 seconds) that is constantly maintained then you would need to find why ntp is unable to connect using port 123 and fix that. (Most likely your router)

Thanks, again. My son is a software engineer in Kansas City for a nationally recognized company. Online he helped me try hundreds of “trys” to rectify that time issue, included going in to check all of my forwarding ports on my router, which he set up and maintains. Nothing worked. We spent 3 hours at this and finally right before I went to bed I did the update. (I normally go to bed at 11 pm and this was at 3 am.) I forwarded the post you sent me to him, because he is the one who guided me through the rss updates and without his help I am useless at this.

I have an extensive collection of video recordings on my main computers which use mythtv as the backends and I enjoy that very much.

Now the schedule’s direct finally also works. We can go back and forth on the reason’s why but I can tell you that without that update, I have a backup of the Raspmc to use on all 3 of our pis. It will be fun to see what the horizon holds for this little electronic wonder.

I need the schedule’s direct to work or the pi is useless to me. Thanks for what you are doing.

I’m experiencing some trouble with wrong time in mine 2015.11-2 version… and I’m under a NAT with my provider that gives me private IP address.
My question is: if I obtain a public IP from my ISP this should solve the problem?

Proper time should not depend on public IP address (I am running NTP via 3 threetimes cascaded NAT). It is more about how your ISP handles the NAT and also the access to the NTP port.
Suggest you post the output of:

sudo journalctl -u ntp
ntpq -c peers
sudo /usr/bin/http-time

either you run the command and post the output or you pipe it to paste-log and post the URL’s here

sudo journalctl -u ntp | paste-log
ntpq -c peers | paste-log
sudo /usr/bin/http-time | paste-log

Last login: Thu Dec 24 10:04:56 2015 from 192.168.1.100
osmc@osmc:~$ sudo journalctl -u ntp
– Logs begin at Fri 2015-12-11 15:39:55 CET, end at Thu 2015-12-24 10:13:48 CET
Dec 11 15:41:09 osmc ntpd[614]: ntpd 4.2.6p5@1.2349-o Wed Oct 28 20:37:00 UTC 20
Dec 11 15:41:09 osmc ntp[608]: Starting NTP server: ntpd.
Dec 11 15:41:09 osmc ntpd[615]: proto: precision = 1.146 usec
Dec 11 15:41:09 osmc ntpd[615]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Dec 11 15:41:09 osmc ntpd[615]: Listen and drop on 1 v6wildcard :: UDP 123
Dec 11 15:41:09 osmc ntpd[615]: Listen normally on 2 lo 127.0.0.1 UDP 123
Dec 11 15:41:09 osmc ntpd[615]: Listen normally on 3 eth0 192.168.1.131 UDP 123
Dec 11 15:41:09 osmc ntpd[615]: Listen normally on 4 lo ::1 UDP 123
Dec 11 15:41:09 osmc ntpd[615]: peers refreshed
Dec 11 15:41:09 osmc ntpd[615]: Listening on routing socket on fd #21 for interf
lines 1-11/11 (END)

That looks fine, how about the other two commands?

Last login: Thu Dec 24 10:10:59 2015 from 192.168.1.104
osmc@osmc:~$ ntpq -c peers
remote refid st t when poll reach delay offset jitter

212.121.88.250 .STEP. 16 u - 1024 0 0.000 0.000 0.000
saguaro.bilink. .STEP. 16 u - 1024 0 0.000 0.000 0.000
192.71.245.44 .STEP. 16 u - 1024 0 0.000 0.000 0.000
*gw-fi.esaote.co 62.48.53.90 3 u 108 256 377 42.551 -3.185 1.394
osmc@osmc:~$

osmc@osmc:~$ sudo /usr/bin/http-time
No internet connectivity was detected within 60 seconds. Will try to send time query anyway.
Updated time from Thu Dec 24 10:15:11 UTC 2015 to Thu Dec 24 10:15:11 UTC 2015 using HTTP query to www.google.com
osmc@osmc:~$

Why in

sudo journalctl -u ntp

the log reports:

– Logs begin at Fri 2015-12-11 15:39:55 CET, end at Thu 2015-12-24 10:13:48 CET

2015-12-11 it’s the wrong date…

Well hard to say as the ntp server only is started when the machine boots. Not sure when you last time rebooted.
But looking at your ntpq -c peers the issue is the first 3 NTP server are not working.
Can you post output of cat /etc/ntp.conf

I’ll post in seconds, however i have restarted the machine many times from 2015-12-11, for sure!

.

osmc@osmc:~$ sudo cat /etc/ntp.conf
> # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

> driftfile /var/lib/ntp/ntp.drift

> # Enable this if you want statistics to be logged.
> #statsdir /var/log/ntpstats/

> statistics loopstats peerstats clockstats
> filegen loopstats file loopstats type day enable
> filegen peerstats file peerstats type day enable
> filegen clockstats file clockstats type day enable

> # You do need to talk to an NTP server or two (or three).
> #server ntp.your-provider.example

> # pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
> # pick a different set every time it starts up. Please consider joining the
> # pool: http://www.pool.ntp.org/join.html
> server 0.debian.pool.ntp.org iburst
> server 1.debian.pool.ntp.org iburst
> server 2.debian.pool.ntp.org iburst
> server 3.debian.pool.ntp.org iburst

> # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
> # details. The web page http://support.ntp.org/bin/view/Support/AccessRestrictions
> # might also be helpful.
> #
> # Note that “restrict” applies to both servers and clients, so a configuration
> # that might be intended to block requests from certain clients could also end
> # up blocking replies from your own upstream servers.

> # By default, exchange time with everybody, but don’t allow configuration.
> restrict -4 default kod notrap nomodify nopeer noquery
> restrict -6 default kod notrap nomodify nopeer noquery

> # Local users may interrogate the ntp server more closely.
> restrict 127.0.0.1
> restrict ::1

> # Clients from this (example!) subnet have unlimited access, but only if
> # cryptographically authenticated.
> #restrict 192.168.123.0 mask 255.255.255.0 notrust

> # If you want to provide time to your local subnet, change the next line.
> # (Again, the address is an example only.)
> #broadcast 192.168.123.255

> # If you want to listen to time broadcasts on your local subnet, de-comment the
> # next lines. Please do this only if you trust everybody on the network!
> #disable auth
> #broadcastclient
> osmc@osmc:~$