Synchronizing Local Time with an NTP Server on Ancor Server

Modified on Sun, 16 Mar at 1:38 PM

Overview 

Accurate time synchronization is critical for ensuring the seamless operation of servers, maintaining accurate logs, and coordinating time-sensitive tasks. This guide provides a step-by-step process to install, configure, and verify the systemd-timesyncd service on Ancor servers. With this setup, your server will synchronize its local clock with the specified Network Time Protocol (NTP) servers, ensuring precise timekeeping for your on-premise deployment. 

 
Applicable Platform:  
On-Premises Deployment 

 
Solution: 
Steps to Install and Configure the NTP Client on your Ancor Server 
Follow the steps below to install, configure, and verify the NTP client setup. 

Step 1: Install the systemd-timesyncd Service 
The systemd-timesyncd service is a minimalistic NTP client that synchronizes the system time with specified NTP servers. 

  • Run the following command to install the service 
    sudo apt install systemd-timesyncd 
     
  • Once the installation completes, the service will start automatically. No additional action is required at this stage. 

Step 2: Verify the Service Status 
After installation, confirm that the service is running as expected 

  • Use the following command to check the service status 
    sudo systemctl status systemd-timesyncd 
     
  • The output should display the status as "active (running)." If it does not, troubleshoot by restarting the service using below command: 
    sudo systemctl restart systemd-timesyncd 
    A screenshot of a computer program 
Description automatically generated 

 

Step 3: Configure NTP Servers: 
The systemd-timesyncd service uses the configuration file located at /etc/systemd/timesyncd.conf to define NTP servers. 

  • Open the configuration file for editing 
  • sudo vim /etc/systemd/timesyncd.conf 
     
  • Locate the NTP= line: 
    This line specifies the NTP servers. Add the hostnames or IP addresses of your NTP servers, separated by a space. For example 
    NTP=ntp.server1.com ntp.server2.com 
     
  • Save and close the file: 
    After making changes, save the file and exit the editor. 
     
  • Restart the service to apply changes 
    sudo systemctl restart systemd-timesyncd 
    A computer screen with a red arrow pointing to the right of the computer 
Description automatically generated 



Step 4: Set the Time Zone: 
To ensure time synchronization works accurately, you need to set the correct time zone for your system. 

  • List all available time zones: 
    Run the following command to view all supported time zones: 
    timedatectl list-timezones 
     
  • Filter time zones (optional): 
    If the list is too long, you can filter it to display time zones for a specific continent or region. For example 
    timedatectl list-timezones | grep Europe 
     
  • Set your desired time zone: 
    Use the following command to set the time zone. Replace <timezone> with the desired time zone name (e.g., Europe/London): 
    timedatectl set-timezone <timezone> 
     
  • Verify the time zone setting: 
    To confirm the time zone is set correctly, use 
    timedatectl 
     
    A computer screen with white text 
Description automatically generated 
     
    A screen shot of a computer 
Description automatically generated 
     

 
Step 5: Enable Clock Synchronization 

To ensure your system synchronizes time with the specified NTP servers, enable NTP synchronization. 

  • Run the following command 
    sudo timedatectl set-ntp true 
     
  • This command enables automatic synchronization with the NTP servers defined in /etc/systemd/timesyncd.conf 
     
  • Verify that NTP synchronization is enabled by checking the service status (detailed in the next step). 
     

Step 6: Verify NTP Configuration 
After completing the setup, verify that the system is synchronizing with the specified NTP servers. 

  • View the system time and synchronization status: 

Timedatectl 

Note that ensure the output includes NTP synchronized: yes 

 

  • Check systemd-timesyncd properties 

timedatectl show-timesync 

This command displays the properties of the synchronization service, including the servers being used. 

 

  • View detailed synchronization status: 

timedatectl timesync-status 

This provides a more in-depth view of the synchronization status. 

A screenshot of a computer 


Conclusion 

By completing the steps in this guide, your Ancor server is now configured to synchronize with designated NTP servers, ensuring accurate system time. This configuration supports proper scheduling, reliable logging, and efficient system operations. 

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article