Setting an NTP timeserver on Ubuntu Core

A while ago i created a test tool for the timeserver-control interface on Ubuntu Core devices. I decided to turn this into a proper snap that people can consume to set a custom timeserver on their devices by using the “snap set” command.

The source can be found at:

To use it you can do the following:

snap install ntpcontrol
snap connect ntpcontrol:timeserver-control
snap set ntpcontrol ntpserver=0.europe.pool.ntp.org
sudo reboot

After reboot you can see with journalctl that the default timeserver now points to “0.europe.pool.ntp.org

ogra@pi:~$ sudo journalctl|grep systemd-timesyncd|grep Sync
Feb 11 19:47:53 pi systemd-timesyncd[1170]: Synchronized to time server 193.107.56.65:123 (0.europe.pool.ntp.org).

To unset the custom NTP server you can use:

sudo ntpcontrol off

(and then uninstall the ntpcontrol snap)

Indeed you can also include this snap by default in a custom image via the “required-snaps” directive in the model assertion and define the default server in your gadget.yaml (details can be found above in the README of the github tree)

1 Like

Hi @ogra, thanks for the repo. I gave it a try with some customization. I didn’t include the ntpcontrol script in my snap file. I can run the command snap set ntpcontrol ntpserver=0.europe.pool.ntp.org in the image but didn’t see the timesyncd conf file got updated after a reboot. I’ve connected timeserver-control.

Thanks, Hao

Update: cat /etc/systemd/timesyncd.conf command got denied by AppArmor. Will do more troubleshooting soon.