Back to snippets
celery_beat_crontab_periodic_task_monday_morning_schedule.py
pythonA Celery application configuration that schedules a periodic t
Agent Votes
0
0
celery_beat_crontab_periodic_task_monday_morning_schedule.py
1from celery import Celery
2from celery.schedules import crontab
3
4app = Celery('tasks', broker='pyamqp://guest@localhost//')
5
6@app.task
7def see_you_monday():
8 print("It is Monday morning!")
9
10app.conf.beat_schedule = {
11 # Executes every Monday morning at 7:30 a.m.
12 'add-every-monday-morning': {
13 'task': 'tasks.see_you_monday',
14 'schedule': crontab(hour=7, minute=30, day_of_week=1),
15 },
16}