# 安装前需要卸载ntp,通过apt安装的可以用:
sudo apt-get remove --purge ntp
# 清理:
sudo apt-get autoremove
# 卸载配置文件和数据:
sudo rm -rf /etc/ntp*
sudo rm -rf /var/lib/ntp
# 安装chrony
sudo apt update
sudo apt install chrony
# 配置chrony
sudo vim /etc/chrony/chrony.conf
# 因为想修改本地时间,不去和其他服务器同步,将下面四个pool注释掉。想同步外部时间的可以加上。
#pool ntp.ubuntu.com iburst maxsources 4
#pool 0.ubuntu.pool.ntp.org iburst maxsources 1
#pool 1.ubuntu.pool.ntp.org iburst maxsources 1
#pool 2.ubuntu.pool.ntp.org iburst maxsources 2
# 添加自己作为服务器
server 192.168.20.55
# 为了方便客户端连接权限设置为允许所有
allow all
# 当无法和其他同步时,使用本地的时间给客户端同步
local stratum 10
# 服务重启,能用就行
sudo service chrony restart
sudo systemctl restart chronyd.service
# 设置开机自启
sudo systemctl enable chrony
# 检查chrony状态
sudo systemctl status chrony