安排任务在特定时间每天运行一次|芹菜
以16H UTC 每天运行两个任务
我想安排
from celery.schedules import crontab
CELERY_IMPORTS = ('api.tasks')
CELERY_TASK_RESULT_EXPIRES = 30
CELERY_TIMEZONE = 'UTC'
CELERYBEAT_SCHEDULE = {
'book-task': {
'task': 'api.tasks.get_data',
# At 16h UTC everyday
'schedule': crontab(hour=16),
'args': ({'book'}),
},
'pencils-task': {
'task': 'api.tasks.get_data',
# At 16h UTC everyday
'schedule': crontab(hour=16),
'args': ({'pencil'}),
}
}
。 -pool = Solo 在运行芹菜节拍-A app.celery
启动芹菜节目后运行芹菜工人。
使用上面的配置,我每分钟开始执行两个任务,从16H UTC开始。我的配置有什么问题以及如何修复?
I want to schedule running two tasks at 16h UTC once per day.
To do so, I've implemented this celery config:
from celery.schedules import crontab
CELERY_IMPORTS = ('api.tasks')
CELERY_TASK_RESULT_EXPIRES = 30
CELERY_TIMEZONE = 'UTC'
CELERYBEAT_SCHEDULE = {
'book-task': {
'task': 'api.tasks.get_data',
# At 16h UTC everyday
'schedule': crontab(hour=16),
'args': ({'book'}),
},
'pencils-task': {
'task': 'api.tasks.get_data',
# At 16h UTC everyday
'schedule': crontab(hour=16),
'args': ({'pencil'}),
}
}
I run celery worker -A app.celery --loglevel=info --pool=solo
to run the celery worker after running celery beat -A app.celery
to launch celery beat.
With the config above, I have my two tasks running every minute starting 16h UTC. What is wrong with my config and how to fix ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在
crontab
中指定minute
,而不是通过minute
表示使用默认值*
使用每分钟运行该作业。通过
minute = 0
在小时开始时运行You need to specify
minute
in yourcrontab
, not passingminute
means the default value*
is used which runs the job every minute.Pass
minute=0
to run at the start of the hour