Search code examples
pythoncelerycelerybeat

current date as argument in a task scheduled with celerybeatC


I'm trying to setup a crontab task passing the date at runtime, like this:

 beat_schedule = {
    'mytask': { 
        'task': 'mytask',
        'schedule': crontab(day_of_week='mon,tue,wed,thu,fri,sat', hour=3, minute=0),
        'args': (date.today().strftime('%Y%m%d')),
    },
}

How can I accomplish this?

Thanks


Solution

  • I do not think Celery beat can do that. Workaround that comes first to mind is to write a tiny Celery task that passes date.today().strftime('%Y%m%d') to the mytask. Then you add that task to the Celery beat config instead of the mytask.