Skip to main content

Dramatiq Crontab

dramtiq-crontab logo: person in front of a schedule

Cron style scheduler for asynchronous Dramatiq tasks in Django.

  • setup recurring tasks via crontab syntax
  • lightweight helpers build on robust tools like Dramatiq and APScheduler
  • Sentry cron monitor support

PyPi Version Test Coverage GitHub License

Setup

You need to have Dramatiq installed and setup properly.

python3 -m pip install dramatiq-crontab
# or
python3 -m pip install dramatiq-crontab[sentry]  # with sentry cron monitor support

Add dramatiq_crontab to your INSTALLED_APPS in settings.py:

# settings.py
INSTALLED_APPS = [
    'dramatiq_crontab',
    # ...
]

Finally, you lauch the scheduler in a separate process:

python3 manage.py crontab

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
DRAMATIQ_CRONTAB = {
    "REDIS_URL": "redis://localhost:6379/0",
}

Usage

# tasks.py
import dramatiq
from dramatiq_crontab import cron


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

Interval

If you want to run a task more frequently than once a minute, you can use the interval decorator.

# tasks.py
import dramatiq
from dramatiq_crontab import interval


@interval(seconds=30)
@dramatiq.actor
def my_task():
    my_task.logger.info("Hello World")

Please note that the interval is relative to the time the scheduler is started. For example, if you start the scheduler at 12:00:00, the first run will be at 12:00:30. However, if you restart the scheduler at 12:00:15, the first run will be at 12:00:45.

Sentry Cron Monitors

If you use Sentry you can add cron monitors to your tasks. The monitor's slug will be the actor's name. Like my_task in the example above.

The crontab command

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

Run dramatiq 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 dramatiq-crontab 1.0.12

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

Source distribution (sdist)

Source distribution for dramatiq-crontab 1.0.12
File Size Uploaded
dramatiq_crontab-1.0.12.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dramatiq-crontab 1.0.12
File Interpreter ABI Platform
dramatiq_crontab-1.0.12-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / dramatiq_crontab-1.0.12.tar.gz

Download URL dramatiq_crontab-1.0.12.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6192289cb7fe16aa698cd6a78aa86e40ae4fb1fe043a55a028cfbf3c2299c8dd
BLAKE2b-256 checksum
How to use checksums
922713dd12312f7126f41d3c7787c8a07568a9026d5b546a2c237bb168a6bef2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Aug 6, 2025.

Transparency log

Release files / dramatiq_crontab-1.0.12-py3-none-any.whl

Download URL dramatiq_crontab-1.0.12-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
417d1da76fd423c02466db6e1091bb089cf76596331951447283fb9d6720ab8c
BLAKE2b-256 checksum
How to use checksums
1840802f5afda7f75b6ed61bd88fc71f96f94670ab5efd172e78ced3f82b67a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Aug 6, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.12 This release

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

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