在CentOS系统中,可以使用chronyd
服务来同步时间。以下是设置和启动chronyd
服务的步骤:
chrony
。如果没有安装,可以使用以下命令安装:sudo yum install chrony
chronyd
服务:sudo systemctl start chronyd
chronyd
服务开机自启:sudo systemctl enable chronyd
chronyd
服务状态:sudo systemctl status chronyd
/etc/chrony.conf
文件来自定义chronyd
的配置。例如,可以添加以下行来指定NTP服务器: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
chronyd
服务以使更改生效:sudo systemctl restart chronyd
chronyc
命令查看时间同步状态:chronyc tracking
现在,CentOS系统应该已经使用chronyd
服务与NTP服务器同步时间了。如果需要手动强制同步时间,可以使用以下命令:
sudo chronyc makestep
这将立即更新系统时间,而不等待下一次计划同步。