Centos使用NTP自动检验时间

第一种方法

第一步安装NTP
yum -y install ntp
第二步:使用命令同步
ntpdate cn.pool.ntp.org
第三步:使用crontab定时计划任务
crontab -e
加入以下信息
00 12 * * * /sbin/ntpdate cn.pool.ntp.org       每隔12个小时自动同步         这个随意  规则: 分、时、日、月、星期
第四步:重启crontab计划任务
/sbin/service crond reload

第二种方法

yum -y install ntp

3.  ntp服务

vim  /etc/ntp.conf

注释:

#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

添加:


server 203.107.6.88
restrict 203.107.6.88 nomodify notrap noquery

server 202.112.29.82
restrict 202.112.29.82 nomodify notrap noquery

#ip为203.107.6.88,为广东省深圳市阿里云ntp服务器
#ip为202.112.29.82,为东北大学ntp服务器

重启:
systemctl restart  ntpd.service
systemctl enable ntpd
ntpq -p

Centos6的时间校验

yum -y install ntp

/etc/init.d/ntpd stop
/usr/sbin/ntpdate cn.pool.ntp.org
/etc/init.d/ntpd start

上面可以写成一个脚本来自动校验时间

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值