1

When I follow steps below in Ubuntu, NTP is enabled and synchronised. However, the case is opposite in Debian Jessie. Anybody knows the reason why Debian says "no"? Also should I worry at all since the "Local time" is correct?

Steps taken

$ timedatectl set-timezone Europe/London

$ sudo apt-get install -y ntp

$ cat /etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
server 0.uk.pool.ntp.org iburst
server 1.uk.pool.ntp.org iburst
server 2.uk.pool.ntp.org iburst
server 3.uk.pool.ntp.org iburst
restrict 127.0.0.1
restrict ::1

$ service ntp stop
$ ntpd -gq
$ service ntp start

$ systemctl enable ntp
$ systemctl restart ntp

Debian Status

$ timedatectl
      Local time: Sun 2018-05-27 08:57:32 BST
  Universal time: Sun 2018-05-27 07:57:32 UTC
        RTC time: Sun 2018-05-27 07:57:30
       Time zone: Europe/London (BST, +0100)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2018-03-25 00:59:59 GMT
                  Sun 2018-03-25 02:00:00 BST
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2018-10-28 01:59:59 BST
                  Sun 2018-10-28 01:00:00 GMT


$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+h88-150-240-202 217.114.59.66    3 u   36   64    1   10.349   -1.919   0.882
*ntp3.wirehive.n 195.66.241.2     2 u   33   64    3   13.717   -0.094   1.398
+ns1.do.steersne 195.66.241.3     2 u   32   64    3    9.994   -1.230   0.947

Ubuntu Status

$ timedatectl
      Local time: Sun 2018-03-14 10:51:48 GMT
  Universal time: Sun 2018-03-14 10:51:48 UTC
        RTC time: Sun 2018-03-14 10:51:46
       Time zone: Europe/London (GMT, +0000)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no
BentCoder
  • 331
  • 6
  • 21
  • Did you try `timedatectl set-ntp true`? – Thomas May 27 '18 at 08:58
  • I've done so much research but never seen that command anywhere or I somehow missed it. That did the trick! If you answer the question I can accept it. Thanks. – BentCoder May 27 '18 at 09:22

1 Answers1

5

To enable time synchronization with timedatectl use the command as follows.

timedatectl set-ntp true

This will enable the systemd service systemd-timesyncd.service. From man timedatectl.

set-ntp [BOOL]
     Takes a boolean argument. Controls whether network time synchronization is active and enabled (if
     available). This enables and starts, or disables and stops the systemd-timesyncd.service unit. It does not
     affect the state of any other, unrelated network time synchronization services that might be installed on
     the system. This command is hence mostly equivalent to: systemctl enable --now systemd-timesyncd.service
     and systemctl disable --now systemd-timesyncd.service, but is protected by a different access policy.

     Note that even if time synchronization is turned off with this command, another unrelated system service
     might still synchronize the clock with the network. Also note that, strictly speaking,
     systemd-timesyncd.service does more than just network time synchronization, as it ensures a monotonic
     clock on systems without RTC even if no network is available. See systemd-timesyncd.service(8) for details
     about this.

So it is possible that e.g. ntp or chrony are running already but timedatectl might not be aware of that.

Further you might have to configure your NTP servers in /etc/systemd/timesyncd.conf unless you get your NTP servers via DHCP or they might also be configured in a corresponding systemd-networkd.service configuration. For more information refer to man systemd-timesyncd.service.

Thomas
  • 4,225
  • 5
  • 23
  • 28