NTP with Chrony

[Void Linux]

If you’ve noticed that your time (like on your dwm bar for dwm users) is lagging behind your phone or wherever else, it's likely a desynced system clock.

Distros which use systemd instead of runit, automatically sync your time in the background using systemd-timesyncd. Void just keeps it minimal and it does not sync your clock to the internet OOTB.

And that is why you need NTP, Network Time Protocol. It is a networking protocol designed to synchronize the clocks of computers over a network.

Computers have internal hardware Real-Time Clocks, but these physical components, which are literally quartz crystals, are imperfect and slowly drift over time due to temperature, age, and battery wear. An NTP daemon connects to highly accurate global time servers (atomic clocks), and constantly adjusts your system clock to ensure it is perfectly accurate.

How to Set Up NTP

You can choose from a variety of NTP daemons, I use Chrony, but you can learn about others here on Void's docs.

Install Chrony

Get chrony package via xbps

sudo xbps-install -Su chrony

Enable the Service

Because Void uses runit, you must enable the service by creating a symlink to the /var/service/ directory.

This tells Void to start Chrony automatically on boot:

sudo ln -s /etc/sv/chronyd /var/service/

Sync it

If your clock is several minutes off, force it to correct the time instantly:

sudo chronyc makestep

Sync Your Hardware Clock

Now that your operating system has the perfect time, write that time back to your motherboard's physical hardware clock so it doesn't start from the wrong time on your next reboot:

sudo hwclock --systohc

That’s it! It will now perfectly match your phone or whatever else, and Chrony will keep it that way.