序:本地测试 短信发送没问题,线上返回 1021 状态码,信息报 time offset too big, more then 600 seconds (时间偏差太大,超过了十分钟)
查看了一下短信发送的错误码:
1021 | 请求发起时间不正常,通常是由于您的服务器时间与腾讯云服务器时间差异超过10分钟导致的 | 请核对服务器时间及 API 接口中的时间字段是否正常 |
说明服务器的时间与本地的时间出现了偏差,查看了一下,确实如此!使用如下命令操作:
# 显示当前时间
[root@xxx ~]# date
# 查看当前时区设置
[root@xxx ~]# timedatectl
# 或
[root@xxx ~]# timedatectl status
# 设置时区
[root@xxx ~]# timedatectl set-timezone "Asia/Shanghai"
# 设置硬件时间
[root@xxx ~]# hwclock --set --date "2022-02-09 10:30:20"
# 将系统时间调整与目前的硬件时间一致
[root@xxx ~]# hwclock --hctosys
### hwclock 的参数:
--adjust hwclock每次更改硬件时钟时,都会记录在/etc/adjtime文件中。使用--adjust参数,可使hwclock根据先前的记录来估算硬件时钟的偏差,并用来校正目前的硬件时钟。
--debug 显示hwclock执行时详细的信息。
--directisa hwclock预设从/dev/rtc设备来存取硬件时钟。若无法存取时,可用此参数直接以I/O指令来存取硬件时钟。
--hctosys 将系统时钟调整为与目前的硬件时钟一致。
--set --date=<日期与时间> 设定硬件时钟。
--show 显示硬件时钟的时间与日期。
--systohc 将硬件时钟调整为与目前的系统时钟一致。
--test 仅测试程序,而不会实际更改硬件时钟。
--utc 若要使用格林威治时间,请加入此参数,hwclock会执行转换的工作。
--version 显示版本信息。