Ubuntu Box 偶尔会浪费时间使用 Twitter API

Ubuntu Box Sporadically Losing Time with Twitter API

我是 运行 一个 digitalocean Ubuntu 盒子,我正在使用 python 和 oauth2 模块捕获 Twitter 的搜索 API。我的脚本在很长一段时间内运行良好,但在脚本明显随机迭代一段时间后,我收到此错误:

 "code":135,"message":"Timestamp out of bounds."

多处暗示并确认这是一个time sync issue with my server and Twitter's API. Some have suggested that the two time's need to be within 30 seconds of each other at all times。有什么我可以 运行 或添加到我的 python 脚本来防止这种间歇性时间同步问题的吗?

更新: Digital Ocean 为其 VPS 服务发布了 guide on setting up time synchronization。这是标准的 NTP 设置,格式易于理解。原始答案没有启动强制同步,因为时钟变化比 ntpd 更正。

原文:

正如您所发现的,Twitter 密切关注时间。值得庆幸的是,这是计算机中一个很好解决的问题。

对于ubuntu,只是运行

sudo apt-get install ntp

这将安装网络时间协议的守护程序,它将您的计算机时钟与世界同步。有关 NTP 的更多信息(如果您好奇的话),请参阅 wikipedia entry for NTP.