centos7 ntp校时离线安装

  1. root用户登陆,进入opt目录,将ntp的三个rpm包拷贝进/opt目录
  2. 分别rpm -ivh 三个rpm包,确保都安装上 其中一个ntpdate包系统自带了,不需要装,npt和ntpdate的版本要完全一致,不然装不上
  rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm  
  rpm -ivh ntp-4.2.6p5-28.el7.centos.x86_64.rpm
  ntpdate-4.2.6p5-28.el7.centos.x86_64.rpm 
  1. 修改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
	#配置上游时间服务器为本地的ntpd Server服务器
	server centos.pool.ntp.org
	fudge centos.pool.ntp.org stratum 0
  1. 手动同步
    1)date 查看当前系统时间
    2)ntpdate -u centos.pool.ntp.org
    3)date查看同步后时间

  2. 启动ntp服务 systemctl start ntpd 开机自启动 systemctl enable ntpd

  3. 修改linux cron表达式
    vim /etc/crontab

  0  1  *  *  * ntpdate -u centos.pool.ntp.org

重启 systemctl restart crond
查看状态 systemctl status crond

阳哥nb