How To Configure Time Synchronization On Ubuntu 18.04 VPS Or Dedicated Server

Introduction

One of the most important components of digital software deployment is accurate timekeeping. Whether you want to record accurate logs or update your database correctly, time synchronization is critical. This tutorial will help you configure time synchronization on your Ubuntu 18.04 VPS or Dedicated server. You will also get to understand some of the most commonly used time-centric commands and master the skills required to implement an optional network time utility. Ready? Let’s go!

Understanding The Basic Ubuntu 18.04 Commands

The most commonly used time command on Ubuntu 18.04 is the date command. This command is used to check the time and date on an Ubuntu server:

$ sudo date

This will deliver an output showing the time and date on your Ubuntu 18.04 system

SunOct 28 16:03:38 UTC 2018

As you can see; from the above command, your Ubuntu server is set to the default UTC timezone. It always nice to consistently set the time zone to the Coordinated Universal Time and avoid spanning infrastructure in multiple time zones. However, if you have projects with complex time requirements, you can easily adjust your time zone using the timedatectl command. To change your timezone, first, run the command below to view a list of the time zones:

$ sudo timedatectl list-timezones

Scroll up and down this list to pinpoint your preferred time zone and note it down. Press q to quit this list, and issue the command to implement this timezone:

 $ sudo timedatectl set-timezoneAmerica/New_York

This will change your time zone to America/New_York. To check if this time zone was properly implemented, execute the command below:

$ sudo date

This will give you the output below:

SunOct 28 12:18:59 EDT 2018

That is it! You now know how to view or change your timezone on Ubuntu 18.04 system.

Implementing The Timesyncd

For long, the ntpd (Network Time Protocol Deamon) has been used to handle time synchronization in Ubuntu systems. The ntpd links with a suite of NTP servers to deliver precise time updates constantly. In spite of its power and usability, the ntpd has been replaced by the timesyncd service in the latest Ubuntu systems. The timesyncd service is almost identical to the ntpd in terms of the way it works and the time server it connects to. However, timesncd has multiple advantages over the ntpd in that its lightweight, integrates seamlessly with the systemd and Ubuntu systems. To check the timesyncd’s status on your Ubuntu 18.04 system, run the command below:

$ sudo timedatectl

This will give you the following output:

   Local time: Sun 2018-10-28 12:54:53 EDT
                    Universal time: Sun 2018-10-28 12:54:53 UTC
                                  RTC time: Sun 2018-10-28 12:54:53
                                 Time zone: America/New_York (EDT, -0400)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

The value YES for the System clock synchronized proves that time is correctly synced and the YES for the systemd-timesyncd.service active indicateds that timesyncd has been enabled and is running properly. In case, the timesyncd in inactive, run the command below to tun it on;

$ sudo timedatectl set-ntpon

Once you enable timesyncd, execute the timedatectl to check the status of the network time.

Changing To Ntpd

The timesyncd is ideal for many purposes, but not all. Some applications are time-sensitive and may be better handled by the ntpd. This is because ntpd utilizes sophisticated techniques and has the ability to handle even the smallest time perturbation. If you are working on the time-sensitive applications, follow the steps below to switch to ntpd utility. First, run the command below to deactivate the timesyncd:

$ sudo timedatectl set-ntpno

Next, issue the command below to check timesyncd’s status:

$ sudo timedatectl

Check to see the value of systemd-timesyncd.service active is no on the output. Now you can execute the command below to install ntp:

$ sudo apt update
$ sudo apt install ntp

The ntpd will be installed and started automatically. Run the command below to check the status details of ntpd:

$ sudo ntpq -p

This will give you the output similar to the one below:

 remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
+ec2-52-0-56-137 216.239.35.0     2 u   16  64    1    7.872   -2.137   1.485
+66.220.10.2     129.6.15.30      2 u   12  64    1   65.204    3.740   2.686
+block.steinhoff 209.51.161.238   2 u   11  64    1   33.364    1.710   3.586
+eterna.binary.n 216.229.0.50     3 u   11  64    1   35.330    2.821   2.839
+2604:a880:800:1 209.51.161.238   2 u   14  64    1    0.394    0.386   2.462
+ec2-52-6-160-3. 130.207.244.240  2 u   11  64    1    8.150    2.050   3.053
+mx.danb.email   127.67.113.92    2 u   13  64    1   63.868    1.539   2.240
*hydrogen.consta 129.6.15.28      2 u   12  64    1    2.989    1.755   2.563
.....

Conclusion

Congratulations! You have learned how to change time zones, check system time, and deploy the default timesyncd. For more information on ntpd, visit NTP’s documentation page.

Check out these top 3 VPS services:

HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Ultahost
$2.90 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How to Install Own Cloud On an an Ubuntu 18.04 Dedicated Server or VPS

You can create your own self-hosted cloud storage services by installing the ope
3 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Enable Two-Factor Authentication on an Ubuntu 18.04 VPS or Dedicated Server

This guide will show you how you enable two-factor authentication to improve the
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Install a Let’s Encrypt Certificate on your Ubuntu 18.04 Dedicated Server or VPS

If you are hosting your website on a VPS server running Ubuntu 18.04, we will sh
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to install OpenLiteSpeed on an Ubuntu 18.04 VPS or Dedicated Server

OpenLiteSpeed is an open source web server characterized by high-performance, li
3 min read
Kennedy Mbuvi
Kennedy Mbuvi
Author
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top