I'm trying to setup django-cron https://github.com/Tivix/django-cron I've finished migrating it but running python2.7 manage.py runcrons throws this error
Make sure these are valid cron class names: ['rest.cron.MyCronJob']
Traceback (most recent call last):
File "/home/kbuzz/lib/python2.7/django_cron/management/commands/runcrons.py", line 35, in handle
crons_to_run = [get_class(x) for x in cron_class_names]
File "/home/kbuzz/lib/python2.7/django_cron/__init__.py", line 23, in get_class
m = __import__(module)
ImportError: No module named cron
I created a file cron.py
in the app rest
and also added the same code to views
from django_cron import CronJobBase, Schedule
import datetime
class MyCronJob(CronJobBase):
RUN_EVERY_MINS = 10 # every 10 minutes
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
code = 'rest.movies_cron' # a unique code
def do(self):
check = file('test.txt','a')
today = datetime.datetime.now()
check.write(today.isoformat())
check.close()
In the settings file I added this, I expect it's a linking issue (code not found).
CRON_CLASSES = [
"rest.cron.MyCronJob",
]