我正在尝试设置 django-cron https://github.com/Tivix/django-cron 我已经完成了迁移但是运行 python2.7 manage.py runcrons 会抛出这个错误
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
我cron.py
在应用程序中创建了一个文件,rest
并将相同的代码添加到视图中
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()
在我添加的设置文件中,我希望这是一个链接问题(找不到代码)。
CRON_CLASSES = [
"rest.cron.MyCronJob",
]