Atlantic.Net Blog

How to Set Up Time Synchronization with NTP on Ubuntu 18.04

Hitesh Jethva
by Atlantic.Net (43posts) under VPS Hosting
0 Comments

Accurate time synchronization over the Internet is a crucial point for any system administrator. If your server time is not synchronized with the correct time zone, you can face data corruption or other issues. NTP, which stands for Network Time Protocol, is a TCP/IP protocol used for synchronizing time over a network. By default, Ubuntu 18.04 uses systemd’s timesyncd service for time synchronization.

In this tutorial, we will show you how you can check whether time synchronization is working on your Ubuntu 18.04 server.

Prerequisites

  • A fresh Ubuntu 18.04 VPS on the Atlantic.Net Cloud Platform.
  • A root password configured on your server.

Step 1 – Create an Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server.  Create a new server, choosing Ubuntu 18.04 as the operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged into your Ubuntu 18.04 server, run the following command to update your base system with the latest available packages.

apt-get update -y

Step 2 – Verify Your Current Time, Date and Time Zone

The easiest way to find your server’s current date and time is date command.

You can run the date command, as shown below, to show your server’s current time and date:

date

You should see the following output:

Thu Feb  6 04:56:55 UTC 2020

Next, you can check whether the time on your servers is activated and whether your server is synchronized with correct time zone using the timedatectl command:

timedatectl

You should get the following output:

                      Local time: Thu 2020-02-06 05:04:49 UTC
                  Universal time: Thu 2020-02-06 05:04:49 UTC
                        RTC time: Thu 2020-02-06 05:04:50
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

In the above output, you should see that the time synchronization is activated and your configured time zone is Etc/UTC.

You can also check the status of the time synchronization service with the following command:

systemctl status systemd-timesyncd.service

You should see the following output:

 • systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-02-06 01:25:58 AST; 2min 39s ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 3106 (systemd-timesyn)
   Status: "Synchronized to time server 91.189.94.4:123 (ntp.ubuntu.com)."
    Tasks: 2 (limit: 2359)
   CGroup: /system.slice/systemd-timesyncd.service
           └─3106 /lib/systemd/systemd-timesyncd

Feb 06 01:25:58 ubuntu1804 systemd[1]: Starting Network Time Synchronization...
Feb 06 01:25:58 ubuntu1804 systemd[1]: Started Network Time Synchronization.
Feb 06 01:25:58 ubuntu1804 systemd-timesyncd[3106]: Synchronized to time server 91.189.94.4:123 (ntp.ubuntu.com).

Step 3 – Change Time Zone Settings

If you want to change your server’s time zone settings, you can also set it using the timedatectl command.

If you’re not sure about your time zone, you can list the available time zones with the following command:

timedatectl list-timezones

You should see the long list of available time zones in the following screen:

Next, you can set the time zone using the timedatectl set-timezone command.

For example, set your server’s time zone to America/Antigua as shown below:

timedatectl set-timezone America/Antigua

Now, verify the time zone with the following command:

timedatectl

You should see the following output:

Local time: Thu 2020-02-06 01:08:41 AST
                  Universal time: Thu 2020-02-06 05:08:41 UTC
                        RTC time: Thu 2020-02-06 05:08:42
                       Time zone: America/Antigua (AST, -0400)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

Step 4 – Activate/Deactivate Time Synchronization

You can also disable and enable the time synchronization any time using the timedatectl command.

To disable synchronization, run the following command:

timedatectl set-ntp off

Now, verify the changes with the following command:

timedatectl

You should get the following output:

                      Local time: Thu 2020-02-06 01:15:33 AST
                  Universal time: Thu 2020-02-06 05:15:33 UTC
                        RTC time: Thu 2020-02-06 05:15:34
                       Time zone: America/Antigua (AST, -0400)
       System clock synchronized: yes
systemd-timesyncd.service active: no
                 RTC in local TZ: no

You can enable time synchronization at any time with the following command:

timedatectl set-ntp on

You can run the timedatectl command again to confirm the network time status.

Conclusion

In this guide, we reviewed how to see the system time amd date, change the time zone, and enable/disable time synchronization on Ubuntu 18.04. For more information, you can visit the official documentation at NTP Doc.

Get A Free To Use Cloud VPS

Free Tier Includes:
G2.1GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Sales Today! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Case Studies

White Papers

Resources


HIPAA Partners


Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G2.1GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources