Bird
0
0

You want to run a Flask Celery task every Monday at 8:30 AM using Celery Beat. Which beat_schedule entry is correct?

hard📝 Application Q15 of 15
Flask - Background Tasks
You want to run a Flask Celery task every Monday at 8:30 AM using Celery Beat. Which beat_schedule entry is correct?
A{'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week='mon')}
B{'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week=2)}
C{'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week='tue')}
D{'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week='Monday')}
Step-by-Step Solution
Solution:
  1. Step 1: Understand crontab day_of_week format

    Celery's crontab accepts day_of_week as string names like 'mon', 'tue', or integers 0-6 (0=Sunday).
  2. Step 2: Evaluate options

    {'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week='mon')} uses 'mon' string which is correct. {'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week=2)} uses integer 2 which is Tuesday (0=Sunday). {'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week='tue')} uses 'tue' string which is Tuesday. {'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week='Monday')} uses 'Monday' full name which is not supported.
  3. Final Answer:

    {'task': 'app.weekly_task', 'schedule': crontab(hour=8, minute=30, day_of_week='mon')} -> Option A
  4. Quick Check:

    Use 'mon' string for Monday in crontab [OK]
Quick Trick: Use three-letter lowercase day names like 'mon' for crontab [OK]
Common Mistakes:
MISTAKES
  • Using full day names like 'Monday' instead of 'mon'
  • Using string numbers like '1' instead of integers or names
  • Confusing day_of_week numbering starting at Sunday

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes