vps · 2020年9月11日 0

vps 时间同步

有些vps禁止链接ntp服务器,导致ntpd服务无法连接到时间服务器,会出现时间无法同步的问题,如果你要使用某些科学上网服务的话是要同步时间的。

方法其实也很简单,就是做个定时任务去某个服务器上抓时间然后通过date命令修改服务器vps上的时间

mkdir /html/scripts

cat time.sh

date -s "$(wget -qSO- --max-redirect=0 [google.com](http://google.com/) 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

crontab -l

0 1 * * * /bin/bash /html/scripts/time.sh