CentOS时间同步
安装ntpdate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
[root@node-01 ~] # yum install ntpdate -y
Loaded plugins: fastestmirror Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.163.com
* extras: mirrors.zju.edu.cn
* updates: mirrors.163.com
Resolving Dependencies --> Running transaction check ---> Package ntpdate.x86_64 0:4.2.6p5-10.el6.centos.2 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================ Package Arch Version Repository Size
================================================================================================================================ Installing: ntpdate x86_64 4.2.6p5-10.el6.centos.2 base 78 k
Transaction Summary ================================================================================================================================ Install 1 Package(s) Total download size: 78 k Installed size: 123 k Downloading Packages: ntpdate-4.2.6p5-10.el6.centos.2.x86_64.rpm | 78 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : ntpdate-4.2.6p5-10.el6.centos.2.x86_64 1 /1 Verifying : ntpdate-4.2.6p5-10.el6.centos.2.x86_64 1 /1 Installed: ntpdate.x86_64 0:4.2.6p5-10.el6.centos.2
Complete! |
同步时间
1
2
|
[root@node-01 ~] # /usr/sbin/ntpdate cn.pool.ntp.org
27 Jul 15:24:41 ntpdate[1674]: step time server 85.199.214.101 offset -27705.095972 sec
|
加到定时任务中
1
2
3
4
|
[root@node-01 ~] # crontab -e
[root@node-01 ~] # crontab -l
# time sync * /5 * * * * /usr/sbin/ntpdate cn.pool.ntp.org > /dev/null 2>$1
|
本文转自 运维小当家 51CTO博客,原文链接:http://blog.51cto.com/solin/1951459,如需转载请自行联系原作者