将 Django Celery 周期性任务安排到 运行 不时到其他时间

Schedule Django Celery periodic tasks to run from time to other time

我怎样才能完成 运行Django Celery 任务运行仅在周一至周五以及那些日子仅从美国东部标准时间上午 9 点到下午 5 点?

celery.py

from celery.schedule import crontab


app.conf.beat_schedule = {
    'compute-every-5-seconds': {
         'task': 'sum',
         'schedule': crontab(),
     },
  }

我应该向 crontab() 添加哪些参数,以便 运行 那些日子以及仅在那些时间之间?

celery.py

from celery.schedule import crontab
app.conf.beat_schedule = {
    'compute-every-minute-mon-through-friday-9-to-5': {
         'task': 'sum',
         'schedule': crontab(minute='*/1',
hour='9-17', day_of_week='mon,tue,wed,thu,fri'),
     },
  }

minute='*/1' - 每分钟运行一次

hour='9-17' - 上午 9 点到下午 5 点运行

day_of_week='mon,tue,wed,thu,fri' - 周一到周五

其中大部分都可以在 documentation 页面上找到,请查看!