How to change the time server for the _in built_ internet time in ubuntu 16.04 LTS?

17,648

Solution 1

According to the official documentation at: https://help.ubuntu.com/lts/serverguide/NTP.html

The nameserver to fetch time for timedatectl and timesyncd from can be specified in /etc/systemd/timesyncd.conf and with flexible additional config files in /etc/systemd/timesyncd.conf.d/.

Solution 2

Ubuntu 16.04 uses by default server ntp.ubuntu.com [reference].

To change the default server, edit the config file with an editor:

sudo vi /etc/systemd/timesyncd.conf

Uncomment the NPT= line and define the server you want to be used instead of default:

[Time]
NTP=some.ntp.server.com

To "audit" the time-synchronization events and verify the server that was contacted, use the following command:

cat /var/log/syslog | grep systemd-timesyncd
Share:
17,648

Related videos on Youtube

PaulBags
Author by

PaulBags

Updated on September 18, 2022

Comments

  • PaulBags
    PaulBags over 1 year

    I know there are instructions for installing full NTP, but I'd rather change the default server under the default implementation. This question has come up before for 12.04 LTS, however the answer there:

    edit the value of NTPSERVERS in /etc/default/ntpdate

    appears to be no longer valid.

    • Jos
      Jos over 7 years
      In my /etc/default/ntpdate there is a warning that the file is not actually used, but that /etc/ntp.conf is used instead. There are various time servers mentioned in /etc/ntp.conf, did you try changing that?
    • Anwar
      Anwar over 7 years
      what was the question before 12.04 ?
    • PaulBags
      PaulBags over 7 years
      @Jos: neither of those exist for me on a fresh install of 16.04 LTS (installed in VMware player.)
    • PaulBags
      PaulBags over 7 years
      @Anwar: link
  • PaulBags
    PaulBags over 7 years
    Cheers :). I like to be thorough and check that these changes are actually taking place, the man pages for timesyncd gave me the command "systemctl status systemd-timesyncd.service" as an example; and that showed up the NTP server I'd assigned.
  • Ulrich Stern
    Ulrich Stern over 4 years
    systemctl status systemd-timesyncd can also be used to "audit," see PaulBags comment on the accepted answer (I like yours better). And sudo systemctl restart systemd-timesyncd can be used to force a sync.
  • Vsevolod Gromov
    Vsevolod Gromov over 3 years
    Are ypou sure that this is proper way? Are you surethat config will be not ovverride after systemd-upgrade? Maybe better create conf file under /etc/systemd/timesyncd.conf.d/ntp.conf ?