Set the time on your Debian/Ubuntu VPS
This guide explains how to properly configure the timezone and time synchronization on your Debian/Ubuntu VPS.
HostMyServers has its own NTP server (ntp.infra.hostmyservers.fr), it is highly recommended to configure it to synchronize your VPS time.
Prerequisites
- SSH access to your VPS
- Administration rights (sudo)
Method 1 — systemd-timesyncd (default)
systemd-timesyncd is the lightweight NTP client built into systemd, enabled by default on most Debian/Ubuntu distributions.
-
Connect to your VPS via SSH.
-
Open the configuration file:
sudo nano /etc/systemd/timesyncd.conf -
Modify the
#NTP=line to:NTP=ntp.infra.hostmyservers.fr -
Save the file:
- Press
Ctrl + X - Then
Oto confirm - Press
Enter
- Press
-
Restart the service:
sudo systemctl restart systemd-timesyncd -
Verify that synchronization is active:
timedatectl status
Method 2 — Chrony
Chrony is a more robust alternative to systemd-timesyncd, particularly suited for virtualized environments (VPS, containers). It offers more accurate synchronization and better handling of clock drift.
Installation
sudo apt update && sudo apt install chrony -y
Installing chrony automatically disables systemd-timesyncd to avoid conflicts.
Configuration
-
Open the configuration file:
sudo nano /etc/chrony/chrony.conf -
Find the existing
poolorserverlines and replace them (or add first) with:server ntp.infra.hostmyservers.fr iburstYour configuration should look like this:
server ntp.infra.hostmyservers.fr iburst# Keep the other options in the file (driftfile, makestep, rtcsync…) -
Save the file (
Ctrl + X, thenO, thenEnter). -
Restart the service:
sudo systemctl restart chronysudo systemctl enable chrony
Verification
Display synchronization status:
chronyc tracking
List the NTP sources in use:
chronyc sources -v
The * column in the chronyc sources output indicates the source currently selected for synchronization.
Common verification
To check system time and synchronization status, regardless of the method used:
timedatectl status
Troubleshooting
If you encounter difficulties, make sure that:
- The NTP service in use (
chronyorsystemd-timesyncd) is active:systemctl status chronyorsystemctl status systemd-timesyncd - Only one of the two services is running at a time (they are incompatible with each other)
- Your VPS can reach the NTP server (
ntp.infra.hostmyservers.fr) - You have sufficient rights to modify the configuration