django-cron - A Django application that will run cron jobs for other django apps - Google Project Hosting
2866 단어 application
he django app will allow the site to run code in a cron job like manor without needing to setup a real cron job (Usefull for people hosting on windows or with Hosting companies that do not give you access to setup cron jobs).
To create a Cron Job you create a file called cron.py in your application directory that will contain the jobs you wish to run. Once you have your jobs created you need add two lines to your primary urls.py (Similar to what you need to do for the admin site)
import django_cron
django_cron.autodiscover()
That will go though all your installed apps and see if they have a cron job to registerExample Cron Job included in the application
from django_cron import cronScheduler, Job
# This is a function I wrote to check a feedback email address and add it to our database. Replace with your own imports
from MyMailFunctions import check_feedback_mailbox
class CheckMail(Job):
"""
Cron Job that checks the lgr users mailbox and adds any approved senders' attachments to the db
"""
# run every 300 seconds (5 minutes)
run_every = 300
def job(self):
# This will be executed every 5 minutes
check_feedback_mailbox()
cronScheduler.register(CheckMail)
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Pre-Query SamplesValidate the current query criteria or provide additional query criteria programmatically, just before sending the SELEC...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.