Ubuntu 中使用 ntpdate 同步网络时间

Ubuntu 中使用 ntpdate 同步网络时间

问题

环境:Homestead > Ubuntu16.04 LTS

最近在测试腾讯云短信接口的时候返回错误信息:

1
# time offset too big, more then 600 seconds

社区问答:云短信“拉取单个手机短信接口“无法使用???

检查一遍代码,并没有问题,故查看了一下 Ubuntu 的系统时间

1
2
$ date
Mon Jul 16 22:27:23 CST 2018

对比了北京时间,发现出现了几个小时的时差,那么问题确定下来是服务器时间设置问题。

方法

安装 ntpdate 工具

1
$ sudo apt-get install ntpdate

设置系统时间与网络时间同步

1
$ ntpdate 0.centos.pool.ntp.org

将系统时间写入硬件时间

1
$ hwclock –systohc

再次使用 date 查看一下时间,时间同步了。
再次测试下短信接口,手机也收到验证码了。

赞赏