I have a task that is set to run on the first day of every month at 05:00 using celery beat. It has been set as follows in settings.py:
CELERY_BEAT_SCHEDULE = {
'generate_monthly_reports': {
'task': 'api.tasks_reports.generate_monthly_reports',
'schedule': crontab(minute=0, hour=5, day_of_month=1)
},
}
This works well and runs reliably. However, I have recently discovered that it is also run whenever Celery is restarted, e.g. when a server code update is made and celery restarted via supervisor. I am using Celery 5.2.6, Python 3.8 and Django 4.0.4.
How can I prevent this task running when Celery is restarted please?