Knowledge Base
Tutorials
Tutorials
  • How to install Joomla 4.2.2 on Ubuntu 20.04?
  • How to set and execute environment and shell variables in Linux?
  • How to employ Docker containers?
  • How to access PostgreSQL Image?
  • How to add and delete users on Ubuntu 20.04?
  • How to add swap space on Ubuntu 20.04?
  • How to back up, restore, and migrate a MongoDB database on Ubuntu 20.04?
  • How to configure additional SSH keys to your public cloud instance?
  • How to configure static IP on Ubuntu?
  • How to create a CLI with Python Fire on Ubuntu 22.04?
  • How to create a new user and manage permissions in MySQL?
  • How to create an instance with Terraform?
  • How to import and export a MongoDB database on Ubuntu 20.04?
  • How to install 7zip on Ubuntu 20.04?
  • How to install AIDE on Ubuntu 22.04?
  • How to install Anaconda on Ubuntu 20.04?
  • How to install and use Docker on Ubuntu 20.04?
  • How to install and use Elinks on Ubuntu 20.04?
  • How to install and use PostgreSQL on Ubuntu 20.04?
  • How to install Android Studio on Ubuntu 22.04?
  • How to install Angular on Ubuntu 20.04?
  • How to install Ansible on Ubuntu 20.04?
  • How to install Apache Kafka on Ubuntu 20.04?
  • How to install Apache Maven on Ubuntu 20.04?
  • How to install Asterisk on Ubuntu 20.04?
  • How to install Atom Text Editor on Ubuntu 20.04?
  • How to install Blender on Ubuntu?
  • How to install CFEngine3 on Ubuntu 20.04?
  • How to install Code::Blocks on Ubuntu 20.04?
  • How to install Composer on Ubuntu 22.04?
  • How to install Curl on Ubuntu 20.04?
  • How to install Desktop GUI on Ubuntu 20.04?
  • How to install Discord on Ubuntu 22.04?
  • How to install Django on Ubuntu 20.04?
  • How to install Docker Compose on Ubuntu 20.04?
  • How to install ELK on Debian 10 or Debian 11?
  • How to install Fail2ban on Debian 10?
  • How to install FFmpeg on Ubuntu 20.04?
  • How to install Flask on Ubuntu 20.04?
  • How to install Fish Shell in Ubuntu 20.04?
  • How to install Gedit on Ubuntu 20.04?
  • How to install Git on Ubuntu 20.04?
  • How to install Gitea on Ubuntu 20.04?
  • How to install Gitlab on Ubuntu 20.04?
  • How to install Go on Ubuntu 20.04?
  • How to install Google Chrome on Ubuntu 20.04?
  • How to install Gradle on Debian 10?
  • How to install Gradle on Ubuntu 20.04?
  • How to install Grafana on Ubuntu 20.04?
  • How to install Hadoop on Ubuntu 20.04?
  • How to install Homebrew on Linux?
  • How to install JAVA with APT on Ubuntu 20.04?
  • How to install Julia on Ubuntu 20.04?
  • How to install Jupyter on an Ubuntu Linux VM?
  • How to install Kdenlive on Ubuntu 20.04?
  • How to install Logwatch on Ubuntu 20.04?
  • How to install MariaDB on Ubuntu 22.04?
  • How to install Memcached on Debian 10?
  • How to install Microsoft Edge Browser on Ubuntu 22.04?
  • How to install MongoDB on CentOS 7?
  • How to install MongoDB on Linux?
  • How to install Mono on Debian 10?
  • How to Install Mono on Ubuntu 20.04?
  • How to install Mozilla Firefox on Ubuntu 20.04?
  • How to install MySQL on Ubuntu 22.04?
  • How to install Nagios on Ubuntu 20.04?
  • How to install Nginx on CentOS 8?
  • How to install Nginx on Ubuntu 22.04?
  • How to install Node.js on Ubuntu 22.04?
  • How to install NVIDIA CUDA on Ubuntu 20.04?
  • How to install Nvidia Optimus Driver on Ubuntu 22.04?
  • How to install OpenCV on Ubuntu 20.04?
  • How to install Perl on Ubuntu on 22.04?
  • How to install Pacman on Ubuntu 20.04?
  • How to install phpMyAdmin on Ubuntu 20.04?
  • How to install PIP on CentOS 8?
  • How to install Plex media server on Ubuntu 20.04?
  • How to install Podman on Ubuntu 20.04?
  • How to install Poetry on Ubuntu 22.04?
  • How to install Postman on Ubuntu 20.04?
  • How to install ProcessWire on Ubuntu 20.04?
  • How to install PyQuery package on Ubuntu 20.04?
  • How to install Python 3 on Ubuntu 22.04 and set up a programming environment?
  • How to install Python on Windows 10 using UI and Windows command prompt?
  • How to install R on Ubuntu 20.04?
  • How to install Ruby on Rails on Ubuntu 20.04?
  • How to install Ruby on Ubuntu 20.04 and setup programming environment?
  • How to install Rust on Ubuntu 22.04?
  • How to install Samba on Ubuntu 20.04?
  • How to install Skype on Ubuntu 20.04?
  • How to install Rancher on Ubuntu 20.04?
  • How to install Slack on Ubuntu 20.04?
  • How to install Springboot on Ubuntu 20.04?
  • How to install Spyder IDE in Ubuntu?
  • How to install Steam on Ubuntu 20.04?
  • How to install Strapi for Production on Ubuntu 20.04?
  • How to install TeamViewer on Ubuntu 20.04?
  • How to install TensorFlow on Ubuntu 20.04?
  • How to install Apache Web Server on Ubuntu 20.04?
  • How to install the Deno JavaScript Runtime on Ubuntu 20.04?
  • How to install Open LiteSpeed Web Server on Ubuntu 22.04?
  • How to install Sublime Text Editor on Ubuntu 20.04?
  • How to install tix package on Ubuntu 20.04?
  • How to install Vagrant on Ubuntu 20.04?
  • How to install Vim on Ubuntu 20.04?
  • How to install VirtualBox on Ubuntu 20.04?
  • How to install VLC Media Player on Ubuntu 20.04?
  • How to install VMware Workstation Player on Ubuntu 20.04?
  • How to install vscode on Ubuntu 20.04?
  • How to install Webmin on Ubuntu 20.04?
  • How to install Wine on Ubuntu 20.04?
  • How to install WordPress on Ubuntu 20.04?
  • How to install Xibo on Ubuntu 20.04?
  • How to install Zoom on Ubuntu 20.04?
  • How to install Yarn on Ubuntu 20.04?
  • How to keep Ubuntu 22.04 servers updated?
  • How to monitor system authentication logs on Ubuntu 20.04?
  • How to perform basic administration tasks for Storage Devices in Linux?
  • How to set up Jenkins on Ubuntu 20.04?
  • How to setup OpenVPN on Ubuntu 20.04?
  • How to setup time synchronization on Ubuntu 20.04?
  • How to setup a UFW on an Ubuntu or Debian Cloud Server?
  • How to setup SSH keys in Ubuntu 20.04?
  • How to SSH terminal through MobaXterm and PuTTY in Windows?
  • How to Use Ansible to Install and Set Up Docker on Ubuntu 20.04?
  • How to view system users on Ubuntu 20.04?
  • How to make OpenStack accessible through CLI?
  • How to make Block Storage available for Linux?
  • Script for automated incremental backups
  • How to configure a Git repository using Linux CLI?
  • How to enable remote access on MySQL?
  • How to Mount a S3 Bucket on Linux Instance?
  • How to access MySQL database credentials?
  • How to create an incremental backup using CLI?
  • How to set up web-based SQL server on OpenStack instance using SQL image?
Powered by GitBook
On this page
  • Overview
  • Prerequisites
  • Basic Time Commands
  • Controlling timesyncd with timedatectl
  • Switching to ntpd
  • Conclusion

Was this helpful?

How to setup time synchronization on Ubuntu 20.04?

PreviousHow to setup OpenVPN on Ubuntu 20.04?NextHow to setup a UFW on an Ubuntu or Debian Cloud Server?

Last updated 1 year ago

Was this helpful?

Overview

Modern software deployments depend on precise timekeeping. Without it, you could run into hard-to-debug problems like data corruption and errors. Time synchronisation can assist guarantee that your logs are being kept in the proper order and that database updates are properly applied.

Fortunately, time synchronisation is included and enabled by default in Ubuntu 20.04 utilising the systemd's timesyncd service. You will put some general time-related commands into practise, check if timesyncd is running, and install a different network time service in this article.

This article will walk you through installing an alternative network time service, testing that timesyncd is running, and some general time-related commands.

Prerequisites

  • Ubuntu version 20.04 or any other linux equipped system

  • A regular user (non-root) having Sudo privileges

  • Internet connection

Basic Time Commands

  • All users have access to the date command, which displays the time and date as they are right now:

date

Your server will often produce an output using the UTC time zone by default.

  • You can use the timedatectl command to modify your time zone. Run the following command to produce a list of the available time zones:

timedatectl list-timezones

Your screen will display a table of time zones.

Note: You can page up by pressing b, and down by pressing SPACE. Once you've located the right time zone, note it down and then press q to leave the list.

  • The time zone can then be set by using the timedatectl set-timezone command followed by the time zone you discovered in the list.

sudo timedatectl set-timezone America/New_York
  • By running the date command again, you can confirm your changes:

date

The newly selected value will be reflected in the time zone abbreviation.

After configuring time zones and monitoring the time, you may ensure that your time is synchronised correctly in the following step.

Controlling timesyncd with timedatectl

The Network Time Protocol daemon, or ntpd, is used to handle the majority of network time synchronisation. This service links to a network of additional NTP servers, which give it regular, precise time updates.

You can now use timesyncd instead of ntpd with Ubuntu's default installation, though. Similar to timesyncd, systemd connects to the same time servers, but it is more tightly integrated with systemd on Ubuntu.

  • By using the command timedatectl without any parameters, you can check the status of timesyncd.

timedatectl

This command prints the local time, the universal time (which might match the local time if you didn't switch from the UTC time zone), and some network time status data. System clock synchronised: yes signifies that timesyncd is operational, and NTP service: active denotes that the timesyncd is up and running.

sudo timedatectl set-ntp on

Run timedatectl once more to verify the network time status after that. System clock synchronised will finally indicate yes and NTP service will appear as active.

Switching to ntpd

timesyncd will work in most circumstances. However, there are times when an application could be sensitive to any change in time. Ntpd is a different network time service that you can utilise in this situation, the system time is continuously and gradually maintained by ntpd using complex algorithms.

  • You must disable timesyncd prior to installing ntpd in order to avoid conflicts between the two services. This can be achieved by turning off network time synchronisation with the command:

sudo timedatectl set-ntp no
  • Check to see if time synchronization is turned off:

timedatectl

Verify that NTP service: inactive is displayed in your output. This indicates that timesyncd has terminated. You're now prepared to use apt to install the ntp package.

  • Run apt update to update your local package index first.

sudo apt update
  • After that, launch apt install ntp to set up the package:

sudo apt install ntp
  • Following the completion of your installation, ntpd will launch automatically. By asking ntpd for status information, you can make sure everything is operating as intended:

ntpq -p

A query tool for ntpd is called ntpq. The -p flag enquires about the peers or NTP servers that ntpd is linked to. Although your output will change slightly, it will list the standard Ubuntu pool servers in addition to a few others.

Conclusion

You've successfully examined the system time, switched time zones, used Ubuntu's default timesyncd service, and installed ntpd during the course of this tutorial. If you require advanced timekeeping services, you should consult the as well as the, a global network of volunteers who provide a significant portion of the NTP infrastructure.

official NTP literature
NTP Pool Project