NTp failing on Raspberry 3 with ubuntu mate Xenial


#1

Hello

We’ve installed a fresh image of Ubuntu Mate and when booting it we get the wrong date and time. We are connecting the internet over wireless and can ping the various timeservers. We also have an internal timeserver and can ping that.

When removing and reinstalling ntp it worked fine - we checked it with ntpq -pn

However after a reboot it had failed again. Restarting the service and checking systemctl status ntp.service gives:

ntp.service - LSB: Start NTP daemon
Loaded: loaded (/etc/init.d/ntp; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2016-02-11 16:43:42 GMT; 5s ago
 Docs: man:systemd-sysv-generator(8)
Process: 2415 ExecStart=/etc/init.d/ntp start (code=exited, status=5)

 Feb 11 16:43:42 pi systemd[1]: Starting LSB: Start NTP daemon...
 Feb 11 16:43:42 pi systemd[1]: ntp.service: Control process exited, code=exited status=5
 Feb 11 16:43:42 pi systemd[1]: Failed to start LSB: Start NTP daemon.
 Feb 11 16:43:42 pi systemd[1]: ntp.service: Unit entered failed state.
 Feb 11 16:43:42 pi systemd[1]: ntp.service: Failed with result 'exit-code'.

Has anyone else seen this issue and have any resolutions please?


#2

So, I have the exact same issue. I came here looking for answers, but found this. I will post if I solve it.

To begin troubleshooting, I am checking the contents of my

/etc/ntp.conf

with

nano /etc/ntp.conf

I read somewhere that ntp is focused on Ethernet and not the wireless service of the Pi, that might have something to do with it.


#3

Have you checked the servers in the configs?

https://www.raspberrypi.org/forums/viewtopic.php?f=50&t=178418


#4

Also, does the wifi connect on boot, or does it require a user login before it connects?


#5

Hi, sorry to gravedig but I also observed this issue on a fresh copy of Ubuntu Mate 16.04 LTS with the latest updates (on RPi3). The package ntp (1:4.2.8p4+dfsg-3ubuntu5.9) was already installed, so I just enabled and started it using systemd. It failed to start and produced no meaningful error messages:

[email protected]:~/rv-utility-server$ sudo systemctl enable ntp
ntp.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable ntp
insserv: warning: current start runlevel(s) (empty) of script `ntp' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (1 2 3 4 5) of script `ntp' overrides LSB defaults (1).
[email protected]:~/rv-utility-server$ sudo systemctl start ntp
Job for ntp.service failed because the control process exited with error code. See "systemctl status ntp.service" and "journalctl -x
e" for details.
[email protected]:~/rv-utility-server$ sudo systemctl status ntp
● ntp.service - LSB: Start NTP daemon
   Loaded: loaded (/etc/init.d/ntp; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-11-09 12:15:21 PST; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 23486 ExecStart=/etc/init.d/ntp start (code=exited, status=5)

Nov 09 12:15:21 rv-server systemd[1]: Starting LSB: Start NTP daemon...
Nov 09 12:15:21 rv-server systemd[1]: ntp.service: Control process exited, code=exited status=5
Nov 09 12:15:21 rv-server systemd[1]: Failed to start LSB: Start NTP daemon.
Nov 09 12:15:21 rv-server systemd[1]: ntp.service: Unit entered failed state.
Nov 09 12:15:21 rv-server systemd[1]: ntp.service: Failed with result 'exit-code'.
[email protected]:~/rv-utility-server$ sudo timedatectl
Failed to query server: No such device
[email protected]:~$ sudo service ntp start
Job for ntp.service failed because the control process exited with error code. See "systemctl status ntp.service" and "journalctl -xe" for details.

I found a relatively recent blog post that seems to describe this problem, but the provided solution (changing the pool directives to server directives) did not work for me.

There is also a seemingly relevant issue filed with the package maintainers, but, again, the provided solution (uinstall ntpdate) is not relevant: ntpdate was/is not installed.

[email protected]:~$ apt-cache policy ntpdate
ntpdate:
  Installed: (none)
  Candidate: 1:4.2.8p4+dfsg-3ubuntu5.9
  Version table:
     1:4.2.8p4+dfsg-3ubuntu5.9 500
        500 http://ports.ubuntu.com xenial-updates/main armhf Packages
        500 http://ports.ubuntu.com xenial-security/main armhf Packages
     1:4.2.8p4+dfsg-3ubuntu5 500
        500 http://ports.ubuntu.com xenial/main armhf Packages
[email protected]:~$ ls /etc/network -R
/etc/network:
if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  interfaces.d

/etc/network/if-down.d:
avahi-autoipd  postfix  resolvconf  upstart  wpasupplicant

/etc/network/if-post-down.d:
avahi-daemon  wireless-tools  wpasupplicant

/etc/network/if-pre-up.d:
ethtool  wireless-tools  wpasupplicant

/etc/network/if-up.d:
000resolvconf  avahi-autoipd  avahi-daemon  ethtool  openssh-server  postfix  upstart  wpasupplicant

/etc/network/interfaces.d:

I tried purging and re-installing ntp and it worked immediately:

[email protected]:~/rv-utility-server$ sudo apt purge ntp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  ntp*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1,288 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 165633 files and directories currently installed.)
Removing ntp (1:4.2.8p4+dfsg-3ubuntu5.9) ...
Purging configuration files for ntp (1:4.2.8p4+dfsg-3ubuntu5.9) ...
Processing triggers for man-db (2.7.5-1) ...
[email protected]:~/rv-utility-server$ which ntp
[email protected]:~/rv-utility-server$ sudo apt install ntp
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  ntp-doc
The following NEW packages will be installed:
  ntp
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/465 kB of archives.
After this operation, 1,288 kB of additional disk space will be used.
Selecting previously unselected package ntp.
(Reading database ... 165578 files and directories currently installed.)
Preparing to unpack .../ntp_1%3a4.2.8p4+dfsg-3ubuntu5.9_armhf.deb ...
Unpacking ntp (1:4.2.8p4+dfsg-3ubuntu5.9) ...
Processing triggers for systemd (229-4ubuntu21.6) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up ntp (1:4.2.8p4+dfsg-3ubuntu5.9) ...
Processing triggers for systemd (229-4ubuntu21.6) ...
[email protected]:~/rv-utility-server$ sudo systemctl status ntp
● ntp.service - LSB: Start NTP daemon
   Loaded: loaded (/etc/init.d/ntp; bad; vendor preset: enabled)
   Active: active (running) since Fri 2018-11-09 13:04:32 PST; 21s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/ntp.service
           └─516 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 109:118

Nov 09 13:04:36 rv-server ntpd[516]: Soliciting pool server 131.188.3.221
Nov 09 13:04:37 rv-server ntpd[516]: Soliciting pool server 198.60.22.240
Nov 09 13:04:37 rv-server ntpd[516]: Soliciting pool server 45.33.84.208
Nov 09 13:04:37 rv-server ntpd[516]: Soliciting pool server 209.177.145.40
Nov 09 13:04:37 rv-server ntpd[516]: Soliciting pool server 91.189.89.199
Nov 09 13:04:38 rv-server ntpd[516]: Soliciting pool server 91.189.94.4
Nov 09 13:04:38 rv-server ntpd[516]: Soliciting pool server 193.141.27.1
Nov 09 13:04:38 rv-server ntpd[516]: Soliciting pool server 2001:19f0:5:5626:5400:1ff:feb3:9e6e
Nov 09 13:04:39 rv-server ntpd[516]: Soliciting pool server 91.189.91.157
Nov 09 13:04:39 rv-server ntpd[516]: Soliciting pool server 67.219.95.113
[email protected]:~/rv-utility-server$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.001
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.001
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.001
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.001
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.001
#ec2-34-225-6-20 209.51.161.238   2 u   58   64    3   73.421  -12.170   2.411
+44.190.6.254    127.67.113.92    2 u   60   64    3   37.864   -4.289   4.042
-ns1.backplanedn 173.162.192.156  2 u   60   64    3   96.147   -0.202   3.156
+clock.team-cymr 204.9.54.119     2 u   55   64    3   71.323   -3.550   9.824
-minime.fdf.net  25.151.162.158   3 u   57   64    3   82.699    2.072   2.157
-199.102.46.80 ( .GPS.            1 u   58   64    3   67.468   -5.252  22.754
-ntp4.doctor.com 50.205.244.27    2 u   55   64    3   80.902   -6.538   1.851
-ntp1.rrze.uni-e .DCFp.           1 u   58   64    3  162.755   -9.824   2.180
*clock.xmission. .XMIS.           1 u   54   64    3   36.088   -3.004   1.852
+christensenplac 200.98.196.212   2 u   60   64    3   89.291   -2.067   1.858
-lga1.m-d.net    204.9.54.119     2 u   57   64    3   87.873   -1.894   2.375
 golem.canonical 193.79.237.14    2 u   60   64    3  153.516   -3.108   3.130
 pugot.canonical 17.253.34.125    2 u   56   64    3  153.901   -3.206   3.281
#ts1.sct.de      192.53.103.108   2 u   55   64    3  175.184   -9.056   1.266
 alphyn.canonica 192.36.143.150   2 u   57   64    3   86.479   -3.094   3.095
#67.219.95.113 ( 129.6.15.28      2 u   54   64    3   89.767    1.901  21.035
[email protected]:~/rv-utility-server$

But after a reboot, the service is in error status:

[email protected]:~$ sudo systemctl status ntp
● ntp.service - LSB: Start NTP daemon
   Loaded: loaded (/etc/init.d/ntp; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-11-09 13:07:42 PST; 4min 17s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1202 ExecStart=/etc/init.d/ntp start (code=exited, status=5)

Nov 09 13:07:42 rv-server systemd[1]: Starting LSB: Start NTP daemon...
Nov 09 13:07:42 rv-server systemd[1]: ntp.service: Control process exited, code=exited status=5
Nov 09 13:07:42 rv-server systemd[1]: Failed to start LSB: Start NTP daemon.
Nov 09 13:07:42 rv-server systemd[1]: ntp.service: Unit entered failed state.
Nov 09 13:07:42 rv-server systemd[1]: ntp.service: Failed with result 'exit-code'.

Turns out, of course, I was doing it wrong → new in Ubuntu 16.04, time is handled by the systemd service systemd-timesyncd (named prefer-timesyncd in MATE). This service is a client-only implementation [ref] that can be paired with chrony for ntp service [more reading].

Instead of enabling the ntp service and querying like ntpq -p, I installed chrony and query with chronyc sourcestats:

sudo systemctl disable ntp
sudo apt install chrony -y
chronyc sourcestats
210 Number of sources = 4
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
festalo.com                 7   5   201     +8.066     52.060   -410us  1658us
clock.team-cymru.org        7   5   201     +0.096      2.122   +473us    59us
x.ns.gin.ntt.net            7   3   201     -0.966      5.294    +22us   140us
hadb1.smatwebdesign.com     6   5   136     -0.061      1.916  +7501ns    28us