How to setup Timezone and NTP on Ubuntu 16.04
Introduction of Timezone and NTP on Ubuntu
Time in the server is very important to set and maintain correctly. Because if time configured wrong, it will cause chaos within the server environment, such as data inconsistency, data synchronization failures, and job scheduling problems. To prevent those problem in the future, we need to set timezone and ntp on the server accordingly. For timezone exactly like our local time. And then NTP (Network Time Protocol) to synchronize the time of your servers and remote NTP servers, keeping the time on your machines in perfect order.
In this article, will be shown how to setup timezone and NTP on Ubuntu 16.04. But if you want to know how to setup on centos, please visit here.
Check current timezone
First thing first, we check the data and time our server currently set. The basic command to check date is :
This date command can used by whether as root user or non-root user. Here the result :
Most often your server will default to the UTC time zone. UTC is Coordinated Universal Time, the time at zero degrees longitude. Consistently using Universal Time reduces confusion when your infrastructure spans multiple time zones. For your information, my server will be used in Indonesia. So, i want make my server time synced with WIB (Western Indonesian Time).
Changing the timezone
If we need to change the timezone, we can use the timedatectl command. But, before we change the timezone, we should look at the list of available time zones:
But, that command probably will show all available time zones around the world. How if we just want to check specific time zone. Like mine, WIB Indonesia – I should refer to Jakarta city for the time zone setup. For that purpose, using this command instead :
timedatectl list-timezones | grep Jakarta
If you already know the timezone format for your server, then change it. Use this command :
timedatectl set-timezone Asia/Jakarta
*Change the red color according to your needs.
To verify the changes by running date again.
ntpd or Network Time Protocol daemon is a daemon on the server that can handle synchronization between our server to connects to a pool server of NTP servers that provide constant and accurate time updates.
Before we install ntpd, we should check the status of timesyncd by running this command without argument :
In order to install ntpd, we should turn off timesyncd first.
timedatectl set-ntp no
Verify the changes with timedatectl and Network time on status should no. Then, we could go to the next step, installing ntpd:
apt-get install ntp
Configuring ntpd to add a remote NTP time server through this config file:
Disable default pool server configuration and add servers configuration according to your server location. For me, I using ntp pool server Indonesia :
Servers can be found on the NTP website.
Restart the ntp service :
service ntp restart
Don’t forget to turn on the timesyncd with:
timedatectl set-ntp on
Well, now your server already synced with world time based on your local time.
Thanks a lot for having time to read on this web. Stay tune on this web to receiving more awesome articles.