毎月 1 日に実行されるセロリのタスクをスケジュールするにはどうすればよいですか?
7756 次
2 に答える
15
Celery 3.0 以降、crontab スケジュールは次の引数をサポートするようday_of_month
になりました: http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#crontab-schedulesmonth_of_year
于 2010-12-09T14:00:06.537 に答える
5
これはCrontab スケジュールを使用して行うことができ、次のいずれかで定義できます。
- 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.
},
}
- celery.py構成:
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.
},
}
于 2017-01-04T09:37:47.670 に答える