Search code examples
pythoncroncelery

How to configure celery schedule crontab in python to execute the task from 2pm to 9am, every hour?


I tried it like this:

crontab(hour="14-9")

but it doesn't work. It executes it continuously; as soon as the task ends, it repeats immediately.


Solution

  • According to official celery docs you have to add minute=0 attribute to your crontab call.

    Your code has to be like:

    crontab(hour="14-9", minute=0)