How do I schedule a task with celery that runs on 1st of every month?
You can do this using Crontab schedules and you cand define this either:
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.
},
}
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.
},
}
Since Celery 3.0 the crontab schedule now supports day_of_month
and month_of_year
arguments: http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html#crontab-schedules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With