Cannot create /etc/systemd/timesyncd.conf file

I want to write NTP server configuration to a file /etc/systemd/timesyncd.conf but the file does not get created.

My code to create the file and write to it runs successfully but the file /etc/systemd/timesyncd.conf is still not present afterwards.

If I create /etc/systemd/timesyncd.conf manually, I can delete it from my code, so write access seems to be ok.

I have timeserver-control interface connected:

Interface                   Plug                          Slot                                     Notes
timeserver-control          mysnap:timeserver-control     :timeserver-control                      manual

Is this a core/core18 device? Please include the output of:

$ snap version


$ snap list |grep core

here is a snap that does exactly this …

what system are you running on where this file does not exist ?
it is part of the systemd-timesyncd default files so a host system having this service installed will also have the file, there should be no need to create/remove it… (in fact i think removing it would break timesyncd)

$ snap version
snap    2.45.1+git1514.gf500958
snapd   2.45.1+git1514.gf500958
series  16
kernel  5.3.0-1027-raspi2

$ snap list |grep core
core                   16-2.45.1+git2001.12683cd  9536  latest/edge  canonical*        core
core18                 20200616                   1850  latest/edge  canonical*        base

I checked your snap. You overwrite the config file using “>”. I try to delete the existing file (to clean up any possible previous configuration) and create a new file. Deletion part works, creation does not.

Why should deleting and re-creating the file be an issue?

well, effectively I dont overwrite but replace the file with its own modified content … this is because “sed -i” (in-place replacement) requires to create a .swp file in the same dir which the timeserver-control interface simply does not grant permission to do …