Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django & Celery: How do I schedule a job to run only once using Celery(similar to "at" command in linux)?

I looked at django-celery tutorial and I think it will really help me running the background tasks without letting the users to wait. However, I have a specific requirement in the program such that when user enters a date, django should be able to do the scheduling and defer the execution to a later time. I have used at program before but it gives a lot of permission issues. But when I read the documentation for Celery, I can only see that Celery supports cron like tasks called @periodic_task. I'm sure that it also provides at like mechanism, but I couldn't find any documentation. Can anybody point me to some resources or simply tell me how to achieve that? Thanks.

like image 281
Shang Wang Avatar asked Mar 30 '12 18:03

Shang Wang


2 Answers

The docs state that you can schedule tasks to execute at a specific time, using the eta argument.

like image 128
LaundroMat Avatar answered Oct 19 '22 08:10

LaundroMat


You can supply the countdown or ETA argument to the apply_async() function. By doing so, you can define the earliest time that the task is gonna be executed, but not the exact one (it depends on your queue). For more details see here.

like image 41
hymloth Avatar answered Oct 19 '22 07:10

hymloth