NTP本地时间同步

会有一股神秘感。 提交于 2019-12-02 15:14:12

服务端:

  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 发布!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!