gpt4 book ai didi

Heroku 调度程序 : timed job OK but not for schedulee job

转载 作者:行者123 更新时间:2023-12-05 07:53:58 24 4
gpt4 key购买 nike

我正在关注 this在 Heroku 上安排我的 Django cron 作业。

程序文件:

web: gunicorn tango.wsgi --log-file -
clock: python createStatistics.py

createStatistics.py:

from apscheduler.schedulers.blocking import BlockingScheduler

sched = BlockingScheduler()

@sched.scheduled_job('interval', minutes=1)
def timed_job():
print('This job is run every minute.')

@sched.scheduled_job('cron', day=14, hour=15, minute=37)
def scheduled_job():
print('This job is run on day 14 at minute 37, 3pm.')

sched.start()

timed_job 运行正常,但是,scheduled_job 无效。我是否需要为 apscheduler 设置任何时区信息(我在 settings.py 中设置了 TIME_ZONE)?如果是这样,如何?还是我错过了什么?

最佳答案

特定于 Heroku,由于我尚未弄清楚的原因,似乎您需要在 cron 作业上指定可选的 id 字段才能使它们工作。所以 cron,作业定义现在看起来像这样。

@sched.scheduled_job('cron', id="job_1", day=14, hour=15, minute=37)
def scheduled_job():
print('This job is run on day 14 at minute 37, 3pm.')

关于Heroku 调度程序 : timed job OK but not for schedulee job,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32004769/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com