Comment planifier une tâche avec celery qui s'exécute le 1er de chaque mois?Comment planifier une tâche avec Celery qui s'exécute le 1er de chaque mois?
10
A
Répondre
11
Depuis Céleri 3.0 le calendrier crontab prend désormais en charge day_of_month
et month_of_year
arguments: http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#crontab-schedules
1
Vous pouvez le faire en utilisant Crontab schedules et vous cand définir ce soit:
- dans votre django settings.py :
from celery.schedules import crontab
CELERYBEAT_SCHEDULE = {
'my_periodic_task': {
'task': 'my_app.tasks.my_periodic_task',
'schedule': crontab(0, 0, day_of_month='1'), # Execute on the first day of every month.
},
}
- dans celery.py config:
from celery import Celery
from celery.schedules import crontab
app = Celery('app_name')
app.conf.beat_schedule = {
'my_periodic_task': {
'task': 'my_app.tasks.my_periodic_task',
'schedule': crontab(0, 0, day_of_month='1'), # Execute on the first day of every month.
},
}
Avez-vous lu http://celeryq.org/docs/reference/celery.schedules.html? –
@Deniz: Ne ressemble pas à DoM. –