Coder Social home page Coder Social logo

django-cron's Introduction

Project forked from: https://code.google.com/p/django-cron/

django-cron

The django app will allow the site to run code in a cron job like manor without needing to setup a real cron job (Useful 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 register

Example Cron Job included in the application

from django_cron import cronScheduler, Job

#This is a function I checking 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.