celery / django-celery-beat

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

Celery Periodic task getting executed multiple times #387

Open sandhuharjodh opened 3 years ago

sandhuharjodh commented 3 years ago

I have a celery task that is scheduled to run at a specific time of the day. The problem is this task is getting executed multiple times, so I am receiving the same email at least 2 to 3 times.

Detailed information

@periodic_task(run_every=crontab(hour=7, minute=10))
def send_reminder_email_at_7():
    obj = Service()
    obj.send_email()
    return

On server, I have setup the project using gunicorn and the supervisor Following is the configuration of celery and celery beat

[program:proj_worker]
command=/home/ubuntu/venv/bin/celery -A baseproj worker -l debug
directory=/home/ubuntu/proj/
user=ubuntu
numprocs=1
stdout_logfile=/home/ubuntu/logs/celerylogs/proj_worker.log
stderr_logfile=/home/ubuntu/logs/celerylogs/proj_worker_err.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=998
[program:proj_beat]
command=/home/ubuntu/venv/bin/celery -A baseproj beat -l debug --scheduler django_celery_beat.schedulers:DatabaseScheduler
directory=/home/ubuntu/proj/
user=ubuntu
numprocs=1
stdout_logfile=/home/ubuntu/logs/celerylogs/proj_beat.log
stderr_logfile=/home/ubuntu/logs/celerylogs/proj_beat_err.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=998
auvipy commented 3 years ago

if possible can you try a new version https://github.com/celery/django-celery-beat/releases/tag/v2.2.0?

altipard commented 2 years ago

any further experiences on this issue?

marcinocto commented 2 years ago

Facing the same issue, I am on 2.2.0 already