我将此任务设置为crontab(day_of_month = 1)。但是当它执行任务时继续发送任务应该执行一次。
来自我的 tasks.py
from celery.task.schedules import crontab
@periodic_task(run_every=crontab(day_of_month=1))
def Sample():
...
我错过了什么吗?
答案 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))
这将仅在本月第一天的午夜运行任务。