[Fixed]-Celery beat not picking up periodic tasks

35👍

The root cause, in this case, is that the beat scheduler needs to be started with the appropriate arguments. You supplied the following command:

$ celery -A sandbox worker --loglevel=debug

However, to start celery with a beat schedule, (as opposed to a regular celery worker) you must specify beat rather than worker. Moreover, when using the django_celery_beat extension, it is necessary to use the Database scheduler django_celery_beat.schedulers:DatabaseScheduler rather than the default scheduler celery.beat.PersistentScheduler.

So the corrected command would be:

$ celery -A sandbox beat --loglevel=debug --scheduler django_celery_beat.schedulers:DatabaseScheduler

Supporting documentation

👤sytech

3👍

If you want to run Beat & Worker together, use the --beat flag.

celery -A sandbox worker --beat --loglevel=debug
👤toto11

2👍

I think you did not define the cron shcedule. Where is it stored? Usually it is on disk or in database (django_celery). See http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html

Also, you have to run your worker with a beat option

2👍

Add below code in “init.py” which is in “sandbox” project to pick task to Django admin.

This will make sure the app is always imported when django starts so that task will use this app.

from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ('celery_app',)

Leave a comment