NTP本地时间同步

2019-10-28  本文已影响0人  naxxm

服务端:

  1. 安装时间同步服务:
yum  -y  install  ntp  ntpdate
  1. 修改配置文件:
vim  /etc/ntp.conf
restrict  10.246.91.0  mask  255.255.255.0  nomodify  notrap                          #打开第16行的注释
server  127.127.1.0  iburst                                                                                      #添加本地作为时间,内网环境注释掉其他server配置
  1. 重启服务并查看状态:
systemctl  restart  ntpd
systemctl  status  ntpd

4.若可连接外网,就用网络时间,否则手动设置时间

date  -s  19\10\28
date  -s  10:50:00

客户端

  1. 执行如下命令
[root@i-4c46d2bc ~]# ntpdate -u 192.168.1.1
28 Oct 11:28:55 ntpdate[6680]: step time server 192.168.1.1 offset 28800.660626 sec

2.创建定时任务

crontab -e
*/5 * * * * /usr/sbin/ntpdate  -u 192.168.1.1 && hwclock -w

参考文档

https://blog.csdn.net/xrwwuming/article/details/51496232
https://blog.csdn.net/hellboy0621/article/details/81903091

本文由博客一文多发平台 OpenWrite 发布!

上一篇 下一篇

猜你喜欢

热点阅读