Skip to main content

django-cron

PyPI version Python Versions Django Versions

A Django app for running scheduled tasks (cron jobs) within your Django project. This is a fork of Tivix/django-cron with full Django 5 compatibility.

Features

  • Simple API: Define cron jobs with a clean, Pythonic interface
  • Django 5 Compatible: Fully tested and working with Django 5.x
  • Flexible Scheduling: Support for various schedule types (daily, hourly, custom intervals)
  • Multiple Locking Backends: File, cache, and database-based locking to prevent concurrent runs
  • Job Logging: Track job execution history and debug issues easily
  • No System Cron Required: Jobs run within your Django process

Installation

Install from PyPI:

pip install django-cron-django5

Add django_cron to your INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    'django_cron',
]

Run migrations:

python manage.py migrate django_cron

Quick Start

Create a cron job by subclassing CronJobBase:

from django_cron import CronJobBase, Schedule

class MyCronJob(CronJobBase):
    RUN_EVERY_MINS = 60  # Run every hour

    schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
    code = 'myapp.my_cron_job'  # Unique code

    def do(self):
        # Your code here
        pass

Register your cron job in settings:

CRON_CLASSES = [
    'myapp.cron.MyCronJob',
]

Run cron jobs:

python manage.py runcrons

For continuous execution, use:

python manage.py cronloop

Requirements

  • Python >= 3.9
  • Django >= 4.2, < 6.0

Documentation

For detailed documentation, please visit the GitHub repository.

Contributing

We welcome contributions! Please see our GitHub repository for more information.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits


Development Setup

Pre-requisites

  • Python >= 3.9

We suggest using pyenv to easily manage python versions.

Configure local development setup

  1. Install and activate python:
pyenv install 3.11.13
pyenv virtualenv 3.11.13 djcron
pyenv local djcron
  1. Install project requirements:
pip install -r requirements-dev.txt
  1. Install pre-commit hooks (if pre-commit is installed globally):
pre-commit install

Running Tests

python testmanage.py test django_cron

Release files for django_cron_django5 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django_cron_django5 0.6.1
File Size Uploaded
django_cron_django5-0.6.1.tar.gz 20.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django_cron_django5 0.6.1
File Interpreter ABI Platform
django_cron_django5-0.6.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 45.1 kB

Release files / django_cron_django5-0.6.1.tar.gz

Download URL django_cron_django5-0.6.1.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
568e266bfc7aea2d5d799f26f95191b675caf4d7e5f81a1405acdbf81af7cb97
BLAKE2b-256 checksum
How to use checksums
ae92ef77b0d78dc20fad1818d4dd7a9d2a2d46e3d662e819ace94c5bbb322580
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / django_cron_django5-0.6.1-py2.py3-none-any.whl

Download URL django_cron_django5-0.6.1-py2.py3-none-any.whl
Size 25.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bf1d09ecab3870341ed049cfc1818178f3a515c668dabb4666e34d475a2df096
BLAKE2b-256 checksum
How to use checksums
2771a13c7bdad75ec0a8514279902f9022321c5d7e30284cdf74aacbc8926f7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release history Release notifications | RSS feed

0.6.3

2 release files

0.6.2

2 release files

This release

0.6.1 This release

2 release files

0.6.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page