Tag Archives: time

Linux : Network Time Protocol (ntp) Configuration & Timezone

| Timezone |

First, get the current timezone of your server :
# timedatectl

You should get something like this :-

Local time: Mon 2017-05-08 09:34:14 +08
Universal time: Mon 2017-05-08 01:34:14 UTC
RTC time: Mon 2017-05-08 01:34:14
Time zone: Asia/Kuala_Lumpur (+08, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

If it is not your timezone, change it via this command:-
# timedatectl set-timezone Asia/Kuala_Lumpur

You can get the list of time zone from “/usr/share/zoneinfo” or # timedatectl list-timezones
The other way to know your current timezone is to
# ls -ld /etc/localtime
and the output similar to this
lrwxrwxrwx. 1 root root 39 Aug 3 2015 /etc/localtime -> ../usr/share/zoneinfo/Asia/Kuala_Lumpur

Also you can make symbolic link like this …

# ln -s /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

if not work, also try change this file content

# vim /etc/sysconfig/clock
change to

| Network Time Protocol (NTP) |

Firstly, install the ntp :-

# yum install ntp nptd ntpdate

After that, sync the time :-
# ntpdate -s asia.pool.ntp.org


# vi /etc/ntp.conf

and replace or change setting similar ( Not compulsory, you can just leave it )

server 0.asia.pool.ntp.org iburst
server 1.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
server 3.asia.pool.ntp.org iburst

restart the service

# service ntpd restart
# systemctl restart ntpd.service

other command related to NTP :-

ntpd - Network Time Protocol (NTP) daemon
ntpdate - set the date and time via NTP
ntpdc - special NTP query program
ntpq - standard NTP query program
ntpstat - show network time synchronisation status
ntptime - read and set kernel time variables

please get nearest ntp server list from http://www.pool.ntp.org/zone/my.
Tested on Centos 7 and Centos 6.

references :