0

I have a celery task and i need it to run only next five days at 12.30am. How do i do this using celery-beat. I know how to run it periodically forever but not able to figure out for only next five days Any idea?

Sandeep
  • 53
  • 1
  • 7

1 Answers1

0

Take a look at the celery-beat docs for crontab. Though if this is literally a one time thing, then by definition, it isn't exactly periodic. You could set up a crontab periodic task to run at 12:30am for the next 5 days, but you would have to also remember to manually turn that off.

If you go this route

from celery.schedules import crontab

CELERYBEAT_SCHEDULE = {
    'add-at-midnightish': {
        'task': 'tasks.add',
        'schedule': crontab(hour=0, minute=30,),
        'args': (16, 16),
    },
}

Alternatively, you could use the eta keyword on apply_async as mentioned in the celery faq

Thtu
  • 1,992
  • 15
  • 21
  • Agreed, but i need not turn off it manually. Is there any way of automatically turn off it after five days. – Sandeep May 05 '16 at 12:11