celery / django-celery-beat

Celery Periodic Tasks backed by the Django ORM
Other
1.69k stars 429 forks source link

Periodic task crontab shedule not working #505

Open Elendiar opened 2 years ago

Elendiar commented 2 years ago

Summary:

Include a brief descrioption of the problem here, and fill out the version info below.

Exact steps to reproduce the issue:

common.py

IMPORT_EXPORT_CELERY_INIT_MODULE = "proj.celery"

CELERY_BROKER_URL = environ.get("CELERY_BROKER")
CELERY_RESULT_BACKEND = "django-db"
CELERY_CACHE_BACKEND = "django-cache"
CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
CELERY_TIMEZONE = environ.get("TZ")
CELERY_ENABLE_UTC = False

init.py

from .celery import app as celery_app

__all__ = ('celery_app', )

celery.py

import os
from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.production')

app = Celery('config')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

@app.task(bind=True)
def debug_task(self):
    print(f'Request: {self.request!r}')

tasks.py

from celery import shared_task

@shared_task
def test():
    print('===========TEST CELERY TASK===========')
    return

@shared_task
def test2():
    print('===========TEST CELERY TASK 2===========')
    return

celery.sh

#!/usr/bin/env bash

exec celery --app config worker -B --loglevel=debug --concurrency=1 &
exec celery -A config beat --loglevel=debug --scheduler django_celery_beat.schedulers:DatabaseScheduler

Detailed information

Nothing happens. Interval works fine, but any crontab shedule wont execute. In log nothing happens too. I search same issues since 2018 with celery beat and crontab, change tz and other but nothing help.

eikebartels commented 11 months ago

I have the same problem. Did you find a solution @Elendiar ?