Linux同步网络时间
ntp常用服务器:
中国国家授时中心:210.72.145.44
NTP服务器(上海) :ntp.api.bz
美国:time.nist.gov
复旦:ntp.fudan.edu.cn
微软公司授时主机(美国) :time.windows.com
台警大授时中心(台湾):asia.pool.ntp.org
阿里云ntp服务器:ntp.aliyun.com
centos 7设置时区
timedatectl set-timezone Asia/Shanghai
尝试修改时间:
下载时间同步模块
# yum install ntpdate ntp -y
尝试同步远程服务器
# ntpdate -u ntp.api.bz
[root@vpn ~]# ntpdate -u ntp.api.bz 24 Aug 14:49:10 ntpdate[1411]: step time server 114.118.7.161 offset -28800.593093 sec
加入crontab
# crontab -e
每天的2点钟同步一次网络时间
* 2 * * * /usr/sbin/ntpdate -u ntp.aliyun.com >/dev/null
# echo "*/20 * * * * /usr/sbin/ntpdate -u ntp.api.bz >/dev/null &" >> /var/spool/cron/root
重启定时任务服务(可忽略)
service crond restart
[root@vpn ~]# echo "*/20 * * * * /usr/sbin/ntpdate -u ntp.api.bz >/dev/null &" >> /var/spool/cron/root [root@vpn ~]# service crond restart Stopping crond: [ OK ] Starting crond: [ OK ]
Centos6.5同步网络时间失败
出现如下错误:no server suitable for synchronization found
查看ntpdate 的位置的方法 :which ntpdate
/usr/sbin/ntpdate stdtime.gov.hk
参考博客:
Linux 修正时间并与网络时间同步
https://blog.51cto.com/13718210/2176491