Skip to main content

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.

  1. Connect to your VPS via SSH.

  2. Open the configuration file:

    sudo nano /etc/systemd/timesyncd.conf
  3. Modify the #NTP= line to:

    NTP=ntp.infra.hostmyservers.fr
  4. Save the file:

    • Press Ctrl + X
    • Then O to confirm
    • Press Enter
  5. Restart the service:

    sudo systemctl restart systemd-timesyncd
  6. 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
note

Installing chrony automatically disables systemd-timesyncd to avoid conflicts.

Configuration

  1. Open the configuration file:

    sudo nano /etc/chrony/chrony.conf
  2. Find the existing pool or server lines and replace them (or add first) with:

    server ntp.infra.hostmyservers.fr iburst

    Your configuration should look like this:

    server ntp.infra.hostmyservers.fr iburst

    # Keep the other options in the file (driftfile, makestep, rtcsync…)
  3. Save the file (Ctrl + X, then O, then Enter).

  4. Restart the service:

    sudo systemctl restart chrony
    sudo 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 (chrony or systemd-timesyncd) is active: systemctl status chrony or systemctl 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