设置系统时区
查看时区
timedatectl
选择时区
timedatectl set-timezone Asia/Shanghai
手动设置时间
timedatectl set-time "2022-02-22 09:00:00"
date -s "2022-02-22 09:00:00"
创建软连接设置本地时间
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Chronyd服务
要与任意主机进行同步时
- "CentOS 8"需要安装 chronyd 服务
- "CentOS 7"执行
ntpdate ntp.aliyun.com
即可同步
安装Chronyd服务
yum -y install chrony
添加需要同步的主机
vim /etc/chrony.conf
+ server ntp.aliyun.com iburst
重启服务
systemctl restart chronyd
立即同步
chronyc sources -v
开启时间自动同步
timedatectl set-ntp true