GithubHelp home page GithubHelp logo

erikrose / django-cronjobs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jsocol/django-cronjobs

0.0 3.0 0.0 110 KB

A simple cron-running management command for Django

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

django-cronjobs's Introduction

Django Cronjobs

django-cronjobs is a simple Django app that runs registered cron jobs via a management command.

Installing

To install django-cronjobs, first install via pip or easy_install, then just add cronjobs to your INSTALLED_APPS.

Registering a cron job

django-cronjobs includes a decorator to register a cronjob, and discovers registered jobs in the module <appname>.cron.

For example:

# myapp/cron.py
import cronjobs

@cronjobs.register
def periodic_task():
    pass

django-cronjobs will then recognize periodic_task as a valid job.

Running a cron job

To run a registered cron job, use the cron management command:

$ ./manage.py cron <job_name>

So to run periodic_task from above, you could use:

$ ./manage.py cron periodic_task

Additional arguments can be passed after the name of the task.

Locks

By default, cron jobs are locked so that only one copy of a given job can be running at a time. If you need to override this behavior, you can pass the lock kwarg to register:

from cronjobs import register
@register(lock=False)
def my_cron_job():
    # Multiple instances of me can run simultaneously.

If you run multiple sets of cronjobs on the same file system and need the locks to not collide, set CRONJOB_LOCK_PREFIX to something unique in your Django settings.

django-cronjobs's People

Contributors

davedash avatar

Watchers

 avatar  avatar  avatar

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.