0% found this document useful (0 votes)
77 views5 pages

How To Set Up Time Synchronization With NTP On Ubuntu 18.04

This document provides instructions on how to set up time synchronization using NTP on Ubuntu 18.04. It describes using the timedatectl command to check the current time and time zone, verify that synchronization is enabled and the service is active, change the time zone setting, and enable or disable time synchronization. The steps include updating packages, checking the date and time, verifying synchronization status, listing and setting the time zone, and enabling or disabling the synchronization service.

Uploaded by

mario-zoric-378
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views5 pages

How To Set Up Time Synchronization With NTP On Ubuntu 18.04

This document provides instructions on how to set up time synchronization using NTP on Ubuntu 18.04. It describes using the timedatectl command to check the current time and time zone, verify that synchronization is enabled and the service is active, change the time zone setting, and enable or disable time synchronization. The steps include updating packages, checking the date and time, verifying synchronization status, listing and setting the time zone, and enabling or disabling the synchronization service.

Uploaded by

mario-zoric-378
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

How to Set Up Time Synchronization with NTP on

Ubuntu 18.04
February 20, 2020 by Hitesh Jethva(253 posts) 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 (

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.

You might also like