4

I have a Django website, and I want to have a certain piece of Python code run at regular intervals. What would be a good way to do that?

I know I can cron, but I would prefer the solution to be within Django.

I know there's a module called celery which is supposed to do it, but it requires installing RabbitMQ and configuring it to interact with Apache, which is another thing to maintain, and I prefer to avoid that.

Any suggestions?

Ram Rachum
  • 5,231
  • 7
  • 34
  • 46

3 Answers3

3

Take a look at Chronograph. You may also want to look at the command-extensions and this Stack Overflow question.

Tom
  • 163
  • 1
  • 7
  • 1
    It looks okay, but then I would still have to use cron. Isn't there a way to avoid cron completely? – Ram Rachum Oct 09 '09 at 14:15
  • There probably are a lot of ways to avoid cron, but it's the built-in, tried-and-true way of scheduling tasks in Unix. Do you need to avoid it because of permissions? If not, I think this is the least painful solution. One cron job and then you can do everything via Django. If you want to be able to run scheduled processes, you're going to need something that runs every x time periods to do it and no matter what you cobble together, cron will be at the base of it. It's turtles all the way down. – Tom Oct 09 '09 at 15:04
0

You can try Celery: Distributed Task Queue

http://www.celeryproject.org/

We use this to offload non-realtime tasks but need to be executed immediately, like sending conformation mail to user at http://www.allthingscustomized.com/

Try it out

0

Celery supporting periodic tasks is more like a side-effect really. If you don't need the asynchronous part, it's probably overkill for you. However, if you already depend on it, the periodic tasks are a great addition, and the way it's scheduling actions is very helpful for quite a lot of asynchronous patterns as well. The feature that celery has that cron doesn't (AFAIK), is that it's able to distribute the periodic jobs over multiple servers. Which again, might just be overkill for you.