Linux下使用ntpdate进行时间同步
1、安装ntpdate,执行以下命令
# yum install ntpdate -y
2、手工同步网络时间,执行以下命令,将从time.nist.gov同步时间
# ntpdate 0.asia.pool.ntp.org
若上面的时间服务器不可用,也可以选择以下服务器同步时间
time.nist.gov
time.nuri.net
0.asia.pool.ntp.org
1.asia.pool.ntp.org
2.asia.pool.ntp.org
3.asia.pool.ntp.org
3.同步时间成功后调整硬件时间
#hwclock -w
执行成功后, 查看系统硬件时间(不出意外的话,现在date和hwclock现实的时间均为internet时间)
#date
#hwclock
执行上述命令,显示的时间应该一样的
四、定时执行时间同步任务,所以我们利用crontab -e 来添加定时任务
* */1 * * * root ntpdatetime.nuri.net;hwclock -w
即:每隔一个小时同步一下internet时间。

浙公网安备 33010602011771号