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

Not able to configure cron to run every minute #91

Closed akashpatni closed 7 years ago

akashpatni commented 8 years ago

Hi,

I have used django-cron for setting up cron task for my project and I am able to run the scripts manually with command python manage.py runcrons and it is running for only one time. Now I want to run script for every minute and for that I have to use crontab -e and I have done in the same way as told in documentation but with no success.

Can you please help me on that

somacci commented 8 years ago

I have exactly same problem. If anyone can solutions. Please let me know it.

ihoru commented 8 years ago

This will make your task execute every time you call manage.py runcrons:

schedule = Schedule(run_every_mins=0)

And if you want it to be executed every minute put 1 instead of 0.

Lapeth commented 7 years ago

Setting run_every_mins=1 is error-prone: Consider that the crontab has us run every minute. If there is a slight difference in time offset on each run, the job might not be executed. Say the crontab executes at 08:00:00.02 and then at 08:01:00.01; there is less than a full minute between these timestamps, so django-cron passes on letting the job execute.

tab-cmd commented 7 years ago

@akashpatni see documentation:

  1. Now everytime you run the management command python manage.py runcrons all the crons will run if required. Depending on the application the management command can be called from the Unix crontab as often as required. Every 5 minutes usually works for most of my applications, for example:

This is intended functionality

sankethsj commented 3 years ago

having the same issue. When I write "python manage.py runcrons", it works well for first time. But it wont run every minute. Help!

JedrzejMaluszczak commented 2 years ago

@sankethsj use python manage.py cronloop instead. You need to update django-cron to version 0.6.0