Skip to main content

Django CronTask

Django CronTask: Cron style scheduler for Django's task framework

Cron style scheduler for asynchronous tasks in Django.

  • setup recurring tasks via crontab syntax
  • lightweight helpers build on top of APScheduler
  • Sentry cron monitor support

PyPi Version Test Coverage GitHub License

Setup

You need to have Django's Task framework setup properly.

python3 -m pip install django-crontask
# or
python3 -m pip install django-crontask[sentry]  # with sentry cron monitor support

Add crontask to your INSTALLED_APPS in settings.py:

# settings.py
INSTALLED_APPS = [
    "crontask",
    # ...
]

Finally, you launch the scheduler in a separate process:

python3 manage.py crontask

Setup Redis as a lock backend (optional)

If you use Redis as a broker, you can use Redis as a lock backend as well. The lock backend is used to prevent multiple instances of the scheduler from running at the same time. This is important if you have multiple instances of your application running.

# settings.py
CRONTASK = {
    "REDIS_URL": "redis://localhost:6379/0",
}

Usage

# tasks.py
import logging

from django.tasks import task
from crontask import cron

logger = logging.getLogger(__name__)


@cron("*/5 * * * *")  # every 5 minutes
@task
def my_task():
    logger.info("Hello World")

Advanced Trigger Usage

You can also use other trigger types from APScheduler. Just import the trigger and use it in the cron decorator.

import logging

from django.tasks import task
from django.utils import timezone
from apscheduler.triggers.interval import IntervalTrigger
from crontask import cron

logger = logging.getLogger(__name__)

every_ten_minutes = IntervalTrigger(
    minutes=10, timezone=timezone.get_default_timezone()
)


@cron(every_ten_minutes)
@task
def my_interval_task():
    logger.info("Hello from interval task")

Sentry Cron Monitors

If you use Sentry suitable tasks will be automatically monitored. The monitor's slug will be the actor's name. Like my_task in the example above.

Certain triggers are not supported by Sentry as well as sub-minute intervals. In these cases, no monitor will be created and no telemetry will be sent.

Pass a custom config via sentry_monitor_config or set it to None to disable Sentry monitoring for a single task:

@cron("* * * * *", sentry_monitor_config=None)
@task
def my_task_without_sentry(): ...

The crontask command

$ python3 manage.py crontask --help
usage: manage.py crontask [-h] [--no-task-loading] [--no-heartbeat] [--version] [-v {0,1,2,3}]
                         [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]
                         [--force-color] [--skip-checks]

Run task scheduler for all tasks with the `cron` decorator.

options:
  -h, --help            show this help message and exit
  --no-task-loading     Don't load tasks from installed apps.
  --no-heartbeat        Don't start the heartbeat actor.

Release files for django-crontask 2.0.0

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-crontask 2.0.0
File Size Uploaded
django_crontask-2.0.0.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-crontask 2.0.0
File Interpreter ABI Platform
django_crontask-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / django_crontask-2.0.0.tar.gz

Download URL django_crontask-2.0.0.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1367aaa5be6f401c5fa4516f484208ae2c8c6b722fb56bb88e1383f37f9b459d
BLAKE2b-256 checksum
How to use checksums
265828859776c9c5df7adc1c985342e44813bb271401015043a44429e69eac8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

Release files / django_crontask-2.0.0-py3-none-any.whl

Download URL django_crontask-2.0.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
434c1e2dacd97d2d39b2d85db9082573a4ab7bce8a72be5c5a7f5808ac5003e3
BLAKE2b-256 checksum
How to use checksums
1e6cb87d197ac4beaebf967206181273c3015f9476ac70f57a22d7bf8d42147e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

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