[Answered ]-Rather than using crontab, can Django execute something automatically at a predefined time

2👍

Just for the record – there is also celery which allows to schedule messages for the future dispatch. It’s, however, a different beast than cron, as it requires/uses RabbitMQ and is meant for message queues.

0👍

I have been thinking about this recently and have found django-cron which seems as though it would do what you want.

Edit: Also if you are not specifically looking for Django based solution, I have recently used scheduler.py, which is a small single file script which works well and is simple to use.

0👍

I’ve had really good experiences with django-chronograph.

You need to set one crontab task: to call the chronograph python management command, which then runs other custom management commands, based on an admin-tweakable schedule

0👍

The problem you’re describing is best solved using cron, not Django directly. Since it seems that you need to store data about your ftp uploads in your database (using Django to access it for logs or graphs or whatever), you can make a python script that uses Django which runs via cron.

James Bennett wrote a great article on how to do this which you can read in full here: http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

The main gist of it is that, you can write standalone django scripts that cron can launch and run periodically, and these scripts can fully utilize your Django database, models, and anything else they want to. This gives you the flexibility to run whatever code you need and populate your database, while not trying to make Django do something it wasn’t meant to do (Django is a web framework, and is event-driven, not time-driven).

Best of luck!

Leave a comment