How does synchronize time - CentOS

Environment
  • CentOS x64


Content
Install NTP
#yum install ntp

Set ntpd service
#/sbin/chkconfig ntpd on

Set it to synchronize time with Hong Kong Observatory
#vim /etc/ntp.conf
server stdtime.gov.hk

Synchronize time with Hong Kong Observatory
#/usr/sbin/ntpdate stdtime.gov.hk

Start ntpd service
#/sbin/service ntpd start

Firewall:
iptables -A OUTPUT -p udp --dport 123 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp --sport 123 -m state --state ESTABLISHED -j ACCEPT
Not set the IP Address as:
stdtime.gov.hk: 118.143.17.82, 118.103.146.184

If set, have "ntpdate[20014]: no server suitable for synchronization found"


Appendix: CentOS7
timedatectl set-timezone Asia/Hong_Kong

timedatectl

hwclock -r



Reference


Update
  • +Appendix: CentOS7 @2019-Aug-15