Bird
0
0

You defined this schedule in your Django settings:

medium📝 Debug Q14 of 15
Django - Celery and Background Tasks
You defined this schedule in your Django settings:
beat_schedule = {
  'cleanup-task': {
    'task': 'app.tasks.cleanup',
    'schedule': crontab(minute=0, hour='*')
  }
}
But the task never runs. What is the most likely cause?
AThe task name 'cleanup-task' is invalid
BYou forgot to start the Celery Beat service
CThe crontab syntax is incorrect because minute should be a string
DThe worker must be restarted every hour
Step-by-Step Solution
Solution:
  1. Step 1: Check if Celery Beat is running

    Celery Beat must be running to send scheduled tasks to the worker.
  2. Step 2: Validate other options

    Task names can be any string, crontab accepts integer or string for minute, and workers do not need hourly restart.
  3. Final Answer:

    You forgot to start the Celery Beat service -> Option B
  4. Quick Check:

    Beat service must run for schedules to trigger [OK]
Quick Trick: Always run Celery Beat alongside worker [OK]
Common Mistakes:
MISTAKES
  • Assuming task name format causes failure
  • Thinking crontab minute must be string only
  • Restarting worker unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes