Time is not synced in centos7.3
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.
Solution 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.