Tivix / django-cron

Write cron business logic as a Python class and let this app do the rest! It enables Django projects to schedule cron tasks, tracks their success / failures, manages contention (via a cache) etc. Basically takes care of all the boring work for you :-)
www.tivix.com
MIT License
900 stars 193 forks source link

Is it possible to have a django cronjob only be ondemand? #113

Closed jeremych1000 closed 7 years ago

jeremych1000 commented 7 years ago

RUN_EVERY_MINS=0 will make it run every time, deleting Schedule doesn't error out but fails according to the traceback in the cron job logs, and deleting code errors out.

I want to standardize some of my django management commands all to use django_cron, but I don't want to run them on a schedule.

Is it possible to create a django cronjob that only runs if I explicitly run it through python manage.py runcrons 'some_cron_job'?

msopko81 commented 7 years ago

The best way to set this up would be to set RUN_EVERY_MINS = None and remove the cron from CRON_CLASSES.

When you want to call the cron, pass in the force option:

python manage.py runcrons 'some_cron_job' --force

jeremych1000 commented 7 years ago

Oh yeah, forgot about None. Thanks @msopko81 .