Автоматическое выполнение задач celery каждый день в определенное время на языке python
Здесь я использую python 3.7 и django 3.0
Я хочу запускать задачу celery каждый день в 11:30
Вот мой settings.py
CELERYBEAT_SCHEDULE = {
'create_auto_capacity': {
'task': 'crm.tasks.create_auto_capacity',
'schedule': crontab(minute='30', hour='11')
},
}
Вот мой crm/tasks.py
@celery_app.task()
def create_auto_capacity():
production_settings = ProductionSettings.objects.all()
client_id = []
for i in production_settings:
client_id.append(i.client.id)
client = ''
for id in client_id:
client = Client.objects.get(id=id)
process = ProductionProcess.objects.filter(is_deleted=False,client=client)
capacity = ProductionCapacity.objects.filter(client=client).last()
capacity_last_date = capacity.date
for i in production_settings:
c_time = []
work_time = WorkTime.objects.filter(client=client,day_type='Weekdays').values_list('total_time',flat=True)
for j in work_time:
try:
t = datetime.datetime.combine(capacity_last_date.min, j) - datetime.datetime.min
except:
t = datetime.combine(capacity_last_date.min, j) - datetime.min
x = isinstance(t, timedelta)
y = t.total_seconds() / 60
c_time.append(y)
g = sum(c_time)
capacity = g * i.num_of_people
remaning_time = g * i.num_of_people
ProductionCapacity.objects.create(client=client,date=capacity_last_date,
production_process=i.production_process,number_of_people=i.num_of_people,
capacity=capacity,remaning_time=remaning_time,manual_add=False)
Я хочу запускать этот код (crm/tasks) ежедневно в 11:30, но это не работает