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

Can't run the task at second time #82

Closed mymusise closed 7 years ago

mymusise commented 8 years ago

Hello,I found a problem ,when i run the command python manage.py runcrons ,my task just run one time and wouldn't run anymore. Here is My code:

mobile/cron.py
class SimpleTaskCronJob(CronJobBase):
    RUN_EVERY_MINS = 1    

    schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
    code = 'mobile.cron.SimpleTaskCronJob'

    def do(self):
        print "runing the task "
        msg = "I have done task in %s sec: %s"
settings.py
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_cron',
    'mobile',
)

CRON_CLASSES = [
    "mobile.cron.SimpleTaskCronJob",
]

is there any problem with my code??

FrankMeyer commented 8 years ago

You can add that command to your crontab, there you specify how often it should run. See point 6 here: http://django-cron.readthedocs.org/en/latest/installation.html