[Solved]-Scheduling a regular event: Cron/Cron alternatives (including Celery)

12๐Ÿ‘

โœ…

A simple, non-Celery way to approach things would be to create custom django-admin commands to perform your asynchronous or scheduled tasks.

Then, on Windows, you use the at command to schedule these tasks. On Linux, you use cron.

Iโ€™d also strongly recommend ditching Windows if you can for a development environment. Your life will be so much better on Linux or even Mac OSX. Re-purpose a spare or old machine with Ubuntu for example, or run Ubuntu in a VM on your Windows box.

๐Ÿ‘คBrian Neal

19๐Ÿ‘

I had the same problem, and held off trying to solve it with celery (too complicated) or cron (external to application) and ended up finding Advanced Python Scheduler. Only just started using it but it seems reasonably mature and stable, has decent documentation and will take a number of scheduling formats (e.g. cron style).

From the documentation, running a function at a specific interval.

from apscheduler.scheduler import Scheduler
sched = Scheduler()
sched.start()
def hello_world():
    print "hello world"
sched.add_interval_job(hello_world,seconds=10)

This is non-blocking, and I run something pretty identical by simply importing the module from my urls.py. Hope this helps.

๐Ÿ‘คmrmagooey

1๐Ÿ‘

https://github.com/andybak/django-cron

Triggered by a single cron task but all the scheduling and configuration is done in Python.

๐Ÿ‘คAndy Baker

1๐Ÿ‘

Django Chronograph is a great alternative. You only need to setup one cron then do everything in django admin. You can schedule tasks/commands from django management.

๐Ÿ‘คNoel Pure

Leave a comment