Bird
0
0

Given this Celery Beat schedule snippet in Django settings:

medium📝 component behavior Q13 of 15
Django - Celery and Background Tasks
Given this Celery Beat schedule snippet in Django settings:
beat_schedule = {
  'print-time': {
    'task': 'app.tasks.print_time',
    'schedule': crontab(minute='*/15')
  }
}
What will happen when Celery Beat and worker run?
AThe task will not run due to syntax error
BThe task runs only once at minute 15
CThe task runs every hour at minute 0
DThe task 'print_time' runs every 15 minutes
Step-by-Step Solution
Solution:
  1. Step 1: Interpret crontab(minute='*/15')

    This means the task runs every 15 minutes, at minute 0, 15, 30, 45 of each hour.
  2. Step 2: Understand Celery Beat behavior

    When both Beat and worker run, Beat triggers the task on schedule, so it runs repeatedly every 15 minutes.
  3. Final Answer:

    The task 'print_time' runs every 15 minutes -> Option D
  4. Quick Check:

    crontab '*/15' means every 15 minutes [OK]
Quick Trick: */15 in crontab means every 15 minutes [OK]
Common Mistakes:
MISTAKES
  • Thinking it runs only once
  • Confusing minute '*/15' with fixed minute 15
  • Assuming syntax error without checking carefully

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes