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

Doesn't run task #125

Closed brayan15 closed 6 years ago

brayan15 commented 7 years ago

I defined my task, but doesn't want show, I added a simple code: class MyCronJob(CronJobBase): RUN_EVERY_MINS = 1 # every 2 hours

schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
#code = 'my_app.my_cron_job'    # a unique code

def do(self):
    print('aaa')

and on setting I putted this: CRON_CLASSES = [ "vehicle_control_system.persons.contrab.MyCronJob",

...

]

and later I run django with python manage.py runserver, but never isn't showing

FrankMeyer commented 7 years ago

Hi brayan,

the crons are not executed with the debug-server. They are executed by the command runcrons. Usually you call manage.py runcrons from your crontab every minute. For example: /1 * www-data python /var/www/project/manage.py runcrons > /var/www/project/log/cronjobs.log

brayan15 commented 7 years ago

Ohh I see, but I can run server and crons with this command (manage.py runcrons)??

FrankMeyer commented 7 years ago

No, manage.py runcrons is for running the cron jobs only. This app has nothing to do with the django developement server. You still run manage.py runserver from the command line.