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

call service every 2 minutes without run "python manage.py runcorns" command everytime #147

Closed xporium closed 2 years ago

xporium commented 5 years ago

hi,

from django_cron import CronJobBase, Schedule

class MyCronJob(CronJobBase): RUN_EVERY_MINS = 2 schedule = Schedule(run_every_mins=RUN_EVERY_MINS) code = 'my_app.my_cron_job' # a unique code

def do(self):
    print('test....')

python manage.py runcrons "my_app.cron.MyCronJob"

so my prob is every time i have to run above command?

is there any way print test..... every 2 minute

python manage.py runserver than i can see print test...... every 2 minutes

so how to do this?

cptx032 commented 5 years ago

The cron program of linux will run your script every time but django-cron only will run your job if its passed 2 minutes...so, i think that configure your command in linux cron is enough. Do you are using linux? Or, why you cannot use cron?

msopko81 commented 5 years ago

@xporium is using Windows 10 (from issue title #145). I just finished moving and tomorrow will update the other issue with how I have the task scheduler set up and give details about it. Maybe we can add it to the documentation for setting this up on Windows.

JedrzejMaluszczak commented 2 years ago

180 Done.