0
我必须按时完成任务,因为我使用的是django_cron。 在设定:django_cron只执行一次,调度程序不工作?
INSTALLED_APPS = [
'mailsnake',
'corsheaders',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Avaana_web',
'rest_framework',
'rest_framework.authtoken',
'django_cron',
]
和cron.py
from django_cron import CronJobBase, Schedule,cronScheduler
import datetime,os
class MyCronJob(CronJobBase):
RUN_EVERY_MINS = .3
RETRY_AFTER_FAILURE_MINS = 5
ALLOW_PARALLEL_RUNS = True
schedule = Schedule(run_every_mins=RUN_EVERY_MINS,
retry_after_failure_mins=RETRY_AFTER_FAILURE_MINS)
code = 'my_app.my_cron_job'
def do(self):
print("hello")
但是当我只运行
$ python manage.py runcrons
hello
一次输出显示并结束。
我如何在每30秒后得到输出。
我也安装了django_cron。通过 $ pip install django_cron –
尝试使用'python -u manage.py runcrons'运行 –
从此链接阅读#6 http://django-cron.readthedocs.io/en/latest/installation.html – Anoop