Setting the correct date, time, time zone and synchronization are the first basic steps that you should perform when provisioning your Ubuntu 18.04 server for the first time.
An accurate time on your Linux machine ensures the smooth operation of your server. For instance, if you have some cron jobs, they need to run accurately on the specified timing. Also, the correct date makes sure that logs are recorded in the right order on your machine.
Some applications also rely on the system date to check for updates. So, if your system date/time goes out of sync, your server will be prone to errors and a lot of hard-to-resolve issues.
Time synchronization is enabled by default on Ubuntu 18.04 but it is good to double check that everything is working as expected. Also, you need to change the time zone per your requirement.
The purpose of this guide is to show you how to check, enable and disable date/time synchronization on your Ubuntu 18.04 server.
- A Linux server running Ubuntu 18.04 version(Bionic Beaver)
- A non-root user with sudo privileges
Step 1: Checking your local Ubuntu 18.04 time settings
You can check your Ubuntu 18.04 server local time, time zone and synchronization status by typing the command below on a terminal window. You don’t require to prefix the command with sudo:
The command above will output the information below:
As you can see from the above screen, the server’s Time zone is UTC and the “system clock synchronized” status is already set to “yes”
Step 2: Checking the list of available time zones on Ubuntu 18.04 server
In order for date/time synchronization to work well on your Ubuntu 18.04 server, you need to set the proper time zone.
First, check the available time zones on your Ubuntu 18.04 server by running the command below:
$ timedatectl list-timezones
The command will display all available time zones on your server. This is a very long list. However, you can use the grep command to limit the list to a specific area.
For instance to see a list of all America time zones, type the command below:
$ timedatectl list-timezones | grep -i america
With a narrowed list like the one shown above, you can choose the right time zone for your server.
Step 3: Changing the time zone on Ubuntu 18.04 server
Changing the time zone is very simple on Ubuntu 18.04 server. For instance,to change our server’s time zone to “America/New_York” from our list above, we will use the command below:
$ sudo timedatectl set-timezone America/New_York
We can run the
timedatectl command to ensure that the changes were effected successfully.
Step 4: Enabling/Disabling time synchronization
Ubuntu 18.04 utilizes the time synced daemon which connects to a pool of Network Time Protocol servers to get constant and accurate time updates.
From the image above, we can see the systemd-timesyncd.service active status is already set to “yes”. However, in case it is turned off, you can turn it on by running the command below:
$ sudo timedatectl set-ntp on
You can turn off the timesyncd daemon by typing the command below
$ sudo timedatectl set-ntp off
To confirm the changes, run the timedatectl command.
In this guide, we showed you t view your system date, time and list all the available time zones. We have also taken you through the steps of changing your Ubuntu 18.04 server time zone as well as enabling/disabling time synchronization on the timesyncd daemon. With the above information, you will be able to run your VPS without any problems when it comes to accurate date and time on your server.
Check out the top 3 VPS services: