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

Sponsors

Sponsors

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.

Metadata

Release files for django-crontask 2.2.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.2.0
File Size Uploaded
django_crontask-2.2.0.tar.gz 10.0 kB Details

Built distribution (wheel)

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

Total release size: 20.4 kB

Release files / django_crontask-2.2.0.tar.gz

Download URL django_crontask-2.2.0.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
602a9c661f8382d8161758bfbc7ad6b52c7d47eda6471a15ba3ad0b469e68731
BLAKE2b-256 checksum
How to use checksums
169a0a627154f19de340271882278b323001f5f209450dba2765981406a687d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 10, 2026.

Transparency log

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

Download URL django_crontask-2.2.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddcba084fa9aaaf99c89e9f40bdaab74c15da3d3e02e887e84a00ce91ae7c5dd
BLAKE2b-256 checksum
How to use checksums
1409cb2643099f4c7371999a2d4d67887e2b94eb137e285d867cb9f8c2b87e70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

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