celerybeat设置为crontab(day_of_month = 1)在一个月内多次发送任务

时间:2013-09-18 10:30:02

标签: django celery django-celery celerybeat

我将此任务设置为crontab(day_of_month = 1)。但是当它执行任务时继续发送任务应该执行一次。

来自我的 tasks.py

from celery.task.schedules import crontab

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

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

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

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

这将仅在本月第一天的午夜运行任务。