安装服务

yum install ntpdate
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cloud.aliyuncs.com
 * extras: mirrors.cloud.aliyuncs.com
 * updates: mirrors.cloud.aliyuncs.com
Resolving Dependencies
--> Running transaction check
---> Package ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                   Arch                     Version                                     Repository              Size
=============================================================================================================================
Installing:
 ntpdate                   x86_64                   4.2.6p5-29.el7.centos.2                     base                    87 k

Transaction Summary
=============================================================================================================================
Install  1 Package

Total download size: 87 k
Installed size: 121 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/2.1903/base/packages/ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm is not installed
ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm                                                            |  87 kB  00:00:00     
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 From       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                                                                    1/1 
  Verifying  : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                                                                    1/1 

Installed:
  ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2                                                                                   

Complete!

启动服务

systemctl start ntpdate.service

开机启动

systemctl enable ntpdate
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpdate.service to /usr/lib/systemd/system/ntpdate.service.

同步时间

ntpdate ntp1.aliyun.com
25 Apr 18:16:31 ntpdate[6395]: adjust time server 120.25.115.20 offset -0.000021 sec

定时同步

编辑定时任务文件

vi /etc/crontab

设定定时任务作业

加入以下命令将在每天凌晨 6:00 进行时间同步,NTP 服务器为 ntp1.aliyun.com

00 06 * * * /usr/sbin/ntpdate ntp1.aliyun.com

友情提示:本站所有文章,如无特殊说明或标注,均为何星星原创发布。与此同时,趋于近年来本站的文章内容频繁被他站盗用与机器采集,现已全局禁用网站文字内容操作,了解详情或转载文章请 点此 继续!

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用*标注