python 服务器时间的时间表与我的国家/地区同步

python schedule at server time synced with my country

我正在编写 Python 脚本,我需要使用 Python schedule 模块。

我想每天半夜执行一个作业,所以写了类似

schedule.every().day.at("00:00")

问题是我想在 my 午夜 运行,因为我正在将此脚本上传到服务器我不知道它的位置,也不知道它的时区。

我怎样才能实现我的目标?

时间表不支持时区,pull-request that included the initial changes to support that was rejected (the source for that can be found here

因此,要么查看这些更改,要么 运行 00:00 上的某项内容通过电子邮件向您发送消息,这样您就可以扣除该服务器与您的服务器之间的偏移量。 如果您定期检查,尤其是在较晚的时候 October/March,那么您可以确定服务器是否受本地时间夏令时变化的影响,并相应地进行调整。

from time import gmtime, strftime
print strftime("%z", gmtime())

太平洋标准时间

import time
time.tzname

它returns两个字符串的元组:第一个是本地非DST时区的名称,第二个是本地DST时区的名称。