centos更新系统时间

用ntpdate从时间服务器更新时间
如果你的linux系统根本没有ntpdate这个命令
yum install ntp

安装完了之后,你不要做什么配置,也不需要,直接测试一下
[root@localhost ~]# ntpdate time.nist.gov
22 Oct 21:11:43 ntpdate[5014]: adjust time server 207.200.81.113 offset -0.018788 sec

如果出去上面的内容说明,同步成功了。然后在crontab里面加上以下内容。
*/10 * * * * ntpdate time.nist.gov   #域名或IP 
每隔十分钟同步一次。推荐几个时间服务器。
time.nist.gov
time.nuri.net
asia.pool.ntp.org
asia.pool.ntp.org
asia.pool.ntp.org
asia.pool.ntp.org

猜你喜欢

转载自cooler1217.iteye.com/blog/1997321