#使用阿里云的ntp服务器,time.pool.aliyun.com
#DATE=`date +"%Y-%m-%d %H:%M:%S"` syncSysTime(){ [ -s /etc/chrony.conf ] || yum -y install chrony \cp /etc/chrony.conf /etc/chrony.conf.bak # sed -i '/^server/s/^./#&/;7 iserver time.pool.aliyun.com iburst' /etc/chrony.conf # systemctl restart chronyd.service chronyc sources ntpdate time.pool.aliyun.com hwclock -w echo "=================================================" echo "配置时间同步完成" date echo "=================================================" echo "" sleep 2 }