want to find when the job will be started in celery
-
28-06-2021 - |
Question
i am new to celery
. i have some configuration in celeryconfig.py
as follow:
from datetime import timedelta
BROKER_URL='redis://localhost:6379/0'
CELERY_RESULT_BACKEND="redis"
CELERY_REDIS_HOST="localhost"
CELERY_REDIS_PORT=6379
CELERY_REDIS_DB=0
CELERY_IMPORT=("mail")
CELERYBEAT_SCHEDULE={'runs-every-30-seconds' :
{
'task': 'mail.mail',
'schedule': timedelta(seconds=30),
},
}
i have scheduled that the job will run periodically in 30 seconds. now i want that the jobs should start on 29 aug
at 4:00PM
then how should i configure this??
Solution
You should use Cron instead of timedelta. The Celery documentation discusses this specifically, and provides some useful examples. See Crontab schedules
Here is an example from Celery:
from celery.schedules import crontab
CELERYBEAT_SCHEDULE = {
# Executes every Monday morning at 7:30 A.M
'every-monday-morning': {
'task': 'tasks.add',
'schedule': crontab(hour=7, minute=30, day_of_week=1),
'args': (16, 16),
},
}
To make this work for your condition, you will also need to specify the cron month_of_year
parameter.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow