Celerybeat 同一任务的多个计划
我收到了以下 Celery 节拍任务,每天凌晨 1 点清理 1000 件物品:
from celery.schedules import crontab
from .celery import app as celery_app
celery_app.conf.beat_schedule['maintenance'] = {
'task': 'my_app.tasks.maintenance',
'schedule': crontab(hour=1, minute=0),
'args': (1000,)
}
我想每周日下午 5 点额外清理 5000 件物品。有没有办法添加第二个时间表?
'schedule': crontab(hour=17, minute=0, day_of_week='sunday'),
'args': (5000,)
以及如何确保它们不会重叠?
I got following Celery beat task which cleans 1000 items daily at 1 AM:
from celery.schedules import crontab
from .celery import app as celery_app
celery_app.conf.beat_schedule['maintenance'] = {
'task': 'my_app.tasks.maintenance',
'schedule': crontab(hour=1, minute=0),
'args': (1000,)
}
I want to clean additional 5000 items every Sunday at 5PM. Is there a way to add second schedule?
'schedule': crontab(hour=17, minute=0, day_of_week='sunday'),
'args': (5000,)
And how to ensure they won't overlap?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
任务 1 将每天运行,包括周日,任务 2 将仅在周日运行
Task1 will run every day including sunday and Task 2 will run only on sunday