【问题标题】: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))
这将只在每月第一天的午夜运行任务。