How does the time synchronization work in PureOS?

I am a Linux beginner. :blush:

I have configured PureOS to synchronize its time data over the internet.

How does it work exactly? Which time servers are used?

You may wish to start with the file: /etc/ntp.conf. Things may have changed since those many moons ago, but it is where I commented out the time servers based on error messages I was seeing in the logs. I was not enamored with the idea of my system pinging them anyway.

1 Like

I have cut out all mentions of npt.org from all of my devices, even from my smartphones. I can manually set the time myself without giving any data to this website. :free: :smirk:

Thanks.

I entered service ntp status in the terminal and I got the following result:

● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:ntpd(8)

I am confused. If NTPD is not running how does PureOS synchronize the time?

I guess I have figured out how it works.

As PureOS uses systemd (like Debian) the configuration is done in the file /etc/systemd/timesyncd.conf. Initially its content is commented out completely.

You can check the status by entering systemctl status systemd-timesyncd.service in the terminal. My PureOS was syncing with 2.debian.pool.ntp.org although the file is commented out as I already wrote. You can read the explanation for example on https://manpages.debian.org/testing/systemd/timesyncd.conf.5.en.html:

If this option is not given, a compiled-in list of NTP servers is used instead.

So, if you want to control the time synchronization you need to edit the file and enter your preferred NTP servers.

1 Like

under PureOS 9 Amber (Librem-Mini) mine says :

● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; disabled; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/systemd-timesyncd.service.d
└─disable-with-time-daemon.conf
Active: inactive (dead)
Docs: man:systemd-timesyncd.service(8)

if i leave my Librem-Mini powered-off and disconnected from the wall (no power through it’s PSU) then the next time i log-in (unless i connect to the www) it shows the time as being July 15 2020 (why is that ? no on-board battery to remember time?)

when i go online the system-time-clock auto-updates in vanilla GNOME DE although the auto-update time is set to off (disabled). is it a bug or a feature ? @jeremiah

1 Like

I would guess a combination of two things.

  1. No battery and clock chip for maintaining the time while powered off.
  2. The above service is not running.

You will need to get someone from Purism to confirm whether the first thing is correct.

The point of the second thing is that without a battery and clock chip, systemd-timesyncd should at least keep the time moving forward i.e. when it does get the correct time from the internet, it will store that on disk (presumably also at shutdown) so that the time is at least in the right ball park each time, provided that you boot and connect to the internet fairly regularly.

Possibly you have ntpd and systemd-timesyncd fighting each other. Do you have ntpd installed and running?

I am assuming that you don’t plan for this computer to be airgapped.

sudo which ntpd

/usr/sbin/ntpd

sudo systemctl status ntpd

Unit ntpd.service could not be found.

sudo apt install ntpd

Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package ntpd

Sorry, I think the service and the package are called ntp

To be clear, we don’t want ntp to be installed. Or in any case, you don’t want both ntp and systemd-timesyncd to be active.

Just try

systemctl status ntp

1 Like

ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) bla-bla-bla …

So unless you have a specific desire to run ntpd

sudo apt purge ntp

then reboot the computer and see whether systemd-timesyncd is active and remains active.

You should then see that the time advances normally while the computer is booted, the time freezes at shutdown, the time unfreezes at startup, and then corrects as soon as the computer can get a network connection.

However I would pursue Purism for confirmation that this computer simply doesn’t have a battery and a clock chip to maintain the time while powered off.

I have one computer that has a battery and clock chip but the computer ships with the battery switched off! (That’s because the battery is a rechargeable, hard-wired one.) Did you read the “Quick Start Guide”? :slight_smile:

okay but the time DOES sync when i go online. that’s NOT the issue (if ntp is or not installed).

the real issue is that what can be observed in the screen-grab from above … when i manually try to set it to auto-update in the GNOME-settings-GUI it shows as DISABLED which it should NOT do because it leaves the user with the impression that the time does NOT sync when in reality it does …

a GUI should ALWAYS reflect what the back-end software (or services in this case, are doing - yes they are NOT conflicting but that isn’t the point)

I dunno if @anon10067017 is still with us, but that is definitely a typo. I dunno if it was wrong in his /etc/ntp.conf, or if he accidentally fat-fingered the post. NPT appears to be some sort of quasi-charity. NTP (https://ntp.org) is a home of the venerable Network Time Protocol, which I have used to synchronize my time since I ran OS/2 Warp in the early 1990’s.

by the way the command i used to get rid of ntp is this :

sudo apt autoremove --purge ntp

it took some other no longer dependent packages with it though so beware of that in case you need them …

i confirm that after reboot the GUI works as expected and shows a visual representation as expected. problem solved :slight_smile:

systemd-timesyncd is still there ofc

1 Like

It would still be good to have confirmation from Purism that this computer (Librem Mini) simply doesn’t have a battery and a clock chip to maintain the time while powered off.

my impression is that it does NOT have any of those hw you listed because if i disconnect the power-brick from the UPS during my sleep hours then when i wake up and power-up again the clock is ALWAYS reset to the default July 15th 2020 date (something with that date in the BIOS i imagine)

That shouldn’t happen now that you have fixed your time client. Instead it should reset to the time of last shutdown.

regardless of what should or should not happen, this is what i could observe happening with my Librem-Mini …

What does

ls -l /var/lib/systemd/timesync/clock

initially (at boot, before network is available) and progressively (over time) show for the time on the file while the computer is booted?

1 Like

hmm. i see … yes it seems to be indicating some time (1 day before the current present time)
meaning now it’s 14 oct and it shows it is as 13 oct

when i try to cat out the file it doesn’t show anything …

it still doesn’t explain the 15 july date … might be some config somewhere …