0

I have installed stock CentOS7.3, and install chrony

yum install -y chrony
systemctl start chronyd
systemctl enable chronyd

If I start CentOS, the time is not synced:

$ timedatectl
NTP enabled: yes
NTP synchronized: no

chrony is running, though

$ systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-06-02 12:19:35 JST; 17min ago
  Process: 631 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 608 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 620 (chronyd)
   Memory: 1.2M
   CGroup: /system.slice/chronyd.service
           └─620 /usr/sbin/chronyd

I have to do a manually sudo systemctl restart chronyd to fix the time syncing problem.

Why is that.

Sato
  • 449
  • 2
  • 9
  • 17

2 Answers2

1

NTP takes some time to synchronize. It needs a couple data points, which takes a minute or two.

You can watch the state of peers with commands like chronyc sources. Each server should have a packet received recently, the LastRx column.

timedatectl determines NTP status via the kernel time discipline. It calls adjtimex() and returns false on an error or if STA_UNSYNC. See systemd sources, time-util.c.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34
  • I waited 30mins, still no luck. `[root@localhost ~]# chronyc sources 210 Number of sources = 4 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^+ laika.paina.net 2 6 371 11 -231us[ -231us] +/- 35ms ^- jp.dan.me.uk 2 6 277 11 +11ms[ +11ms] +/- 185ms ^* chobi.paina.net 2 6 377 15 -287us[ -382us] +/- 21ms ^+ sjkBBML24.bb.kddi.ne.jp 5 6 377 12 +794us[ +794us] +/- 59ms` – Sato Jun 05 '17 at 00:53
0

You can also use timedatectl to instruct your OS to accurately maintain the correct time by keeping its time in sync with an another trusted remote “NTP” server. This is done by running the following command:

timedatectl set-ntp yes

We can view a list of trusted ntp servers that the chronyd is using to sync the system-time. You can view this list using the chronyc command:

chronyc sources -v

Also, check the system file in which NTP servers are updated

cat /etc/chrony.conf

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).

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

Alternatively you can also update the ntp server with time zone

timedatectl set-timezone Europe/London
Lacek
  • 7,233
  • 24
  • 28
Ryan
  • 137
  • 4