简体   繁体   English

芹菜定期任务计时错误

[英]Celery periodic task timing error

Currently I have celery periodic-task with the following set-up: 目前,我的芹菜定期任务具有以下设置:

CELERYBEAT_SCHEDULE = {
    'test-celery': {
        'task': 'flask_react_app.task.ingest_stock_data',
        'schedule': crontab(minute='*/17', hour='8-16', day_of_week='mon-fri'),
    }
}

This is almost what I wanted, except, I want the job to start at 08:01 and the finish at 16:30 running every 17 minutes between those times (so 08:01, 08:18, 08:35). 这几乎是我想要的,除了,我希望工作从08:01开始,并在这段时间之间每隔17分钟运行一次16:30结束(因此08:0​​1、08:18、08:35)。 So I tried: 所以我尝试了:

CELERYBEAT_SCHEDULE = {
    'test-celery': {
        'task': 'flask_react_app.task.ingest_stock_data',
        'schedule': crontab(minute='1/17', hour='8-16', day_of_week='mon-fri'),
    }
}

Which gave me the error: 这给了我错误:

ValueError: Invalid weekday literal '1/17'

Even though this literal is in the minute key word argument. 即使此字面量在分钟关键字参数中也是如此。

I'm not sure if I understood you correctly, but you can do the following if you want to run the task periodically every 1 minute, between 8 and 16. 我不确定我是否理解正确,但是如果要每1分钟(在8到16之间)定期运行任务,可以执行以下操作。

CELERYBEAT_SCHEDULE = {
    'test-celery': {
        'task': 'flask_react_app.task.ingest_stock_data',
        'schedule': crontab(minute='*/1', hour='8-16', day_of_week='mon-fri'),
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM