Set timezone and Time Synchronization in Ubuntu 20.04 Server

We often ignore this vital part time synchronization while setting up Ubuntu 20.04 server. By default the time zone of installed ubuntu 20.04 server is set to the cloud hosting server provider’s system time. And if you are installing your web application in the server, then you might want your web application time reference should be according to your local time.

In Ubuntu 20.04 server, we can set the time zone and set time synchronization so that all the time reference should be with respect to your local time.

Login to your ubuntu server using putty. (If you have no idea about it, check the second chapter. All the chapter list are present below of this article)

Timezone set and Synchronization

First of check whether the time is with respect to your local time.

test@tester:~$ date

If you press enter after the above command, then it will print the ubuntu server’s current time.

Output: Sat Aug 8 10:33:48 UTC 2020

I am in India and my web application is located in India. So I need to set the system time zone to India.

So, I need to know what is the time zone name for India is present inside the Ubuntu Server’s record. Following command is going to help me to find out all the timezone names.

test@tester:~$ timedatectl list-timezones

The above command going to list all the installed timezone names. With the help of up key and down key you can find your desired timezone.

Once you find your desired time zone, press q in the keyboard. It will help to return back to the command line mode.

Now its time to set the desired time zone.

In my case the timezone is Asia/Kolkata and with following command I can set the timezone to it.

test@tester:~$ sudo timedatectl set-timezone Asia/Kolkata

After executing the above command, the timezone is set to my desired time zone. For confirmation, I need to check the time.

test@tester:~$ date

Output; Sat Aug 9 10:47:07 IST 2020

From the output I can understand the timezone is set to Indian Standard Time.

Timezone Synchronization

We may often reboot ubuntu operating system for certain reasons. In that case chances are timezone may set back to the default time zone of service provider’s system. So following command helps to find out whether the time zone is synched or not!

test@tester:~$ timedatectl

Local time: Sat 2020-08-08 12:09:36 IST
Universal time: Sat 2020-08-08 06:39:36 UTC
RTC time: Sat 2020-08-08 06:39:37
Time zone: Asia/Kolkata (IST, +0530)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no

Notice System clock synchronized is yes. It means time is synched.