Wie plane ich eine Aufgabe mit celery, die am 1. jeden Monats ausgeführt wird?Wie plane ich eine Aufgabe mit Sellerie, die am 1. jeden Monats läuft?
10
A
Antwort
11
Da Sellerie 3.0 die crontab Zeitplan unterstützt jetzt day_of_month
und month_of_year
Argumente: http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#crontab-schedules
1
Sie können diese mit Crontab schedules tun, und Sie cand dies entweder definieren:
- in Ihrem 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.
},
}
- in 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.
},
}
Haben Sie http://celeryq.org/docs/reference/celery.schedules.html lesen? –
@Deniz: Sieht nicht wie DoM abdeckt. –