Linux服务器(Centos6、Centos7、Centos8、Ubuntu16.04)时间同步方案

注意:请自行替换时间同步服务器$ntpServer的具体ip或者网址,公网可以使用

阿里巴巴:ntp.aliyun.com

腾讯云:server time1.cloud.tencent.com

微软:time.windows.com

苹果:time.apple.com

#1.安装ntpdate软件,已安装的请忽略
apt-get install -y ntpdate
#2.设置定时同步策略
crontab -e 
#添加一行 每天1点1分执行时间同步
1 * * * /usr/sbin/ntpdate $ntpServer
#3.执行立即同步
/usr/sbin/ntpdate $ntpServer
#1.安装ntpdate软件,已安装的请忽略
yum install -y ntpdate
#2.设置定时同步策略
crontab -e 
#添加一行 每天1点1分执行时间同步
1 * * * /usr/sbin/ntpdate time.ta-mp.com
#3.执行立即同步
/usr/sbin/ntpdate time.ta-mp.com
  • FOR Centos 8
#1.安装chrony软件,已安装的请忽略
yum install -y chrony
#2.启动
systemctl start chronyd
#3.设为系统自动启动
systemctl enable chronyd
#4.编辑配置文件
vim /etc/chrony.conf
注释掉如下这行:
#pool 2.centos.pool.ntp.org iburst
添加如下一行:
server $ntpServer
#5.重新加载配置
systemctl restart chronyd.service
#6.执行立即同步
chronyc sources -v

 

Intoep小程序

微信扫一扫,打开小程序浏览更便捷

转载作品,原作者:运维老男孩,文章来源:https://www.toutiao.com/i7054476504079532575

发表回复

登录后才能评论