【问题标题】:celerybeat set to crontab(day_of_month=1) sends task multiple times in a monthcelerybeat 设置为 crontab(day_of_month=1) 在一个月内多次发送任务
【发布时间】:2013-09-23 01:42:16
【问题描述】:

我有这个设置为 crontab(day_of_month=1) 的任务。但是当它执行任务时,它会继续发送任务,该任务应该执行一次。

来自我的 tasks.py

from celery.task.schedules import crontab

@periodic_task(run_every=crontab(day_of_month=1))
def Sample():
...

我错过了什么吗?

【问题讨论】:

    标签: django celery django-celery celerybeat


    【解决方案1】:

    默认情况下,crontab 将每分钟运行一次,因此您需要指定分钟和小时。

    @periodic_task(run_every=crontab(day_of_month=1)) 更改为@periodic_task(run_every=crontab(minute=0, hour=0, day_of_month=1))

    这将只在每月第一天的午夜运行任务。

    【讨论】:

      猜你喜欢
      • 2011-09-21
      • 2014-10-25
      • 1970-01-01
      • 2017-12-14
      • 2017-07-10
      • 1970-01-01
      • 1970-01-01
      • 2020-03-09
      • 2021-04-12
      相关资源
      最近更新 更多