Skip to main content

django-celery-beat-prune

Delete an entry from CELERY_BEAT_SCHEDULE, deploy, and with django-celery-beat the task keeps running. DatabaseScheduler copies your settings into the PeriodicTask table on every Beat start with update_or_create, and nothing ever deletes. The row stays there and stays enabled, firing on schedule. Nothing in the logs says so, and the deploy looks like it worked.

This package adds the missing half. Settings become the schedule, and the table becomes a copy of it: when Beat starts, rows with no entry in CELERY_BEAT_SCHEDULE are removed, and each one is named in the log.

# settings.py
CELERY_BEAT_SCHEDULER = "django_celery_beat_prune.PruningScheduler"

That's the whole setup. Restart Beat, and any task you have removed from settings stops.

Install

pip install django-celery-beat-prune

Add the app if you want the management command:

INSTALLED_APPS = [
    # ...
    "django_celery_beat",
    "django_celery_beat_prune",
]

Requires Python 3.10+, Django 4.2+, Celery 5.3+ and django-celery-beat 2.5+. CI tests both the oldest and the newest of each.

What it does, and what it deliberately doesn't

  • Rows are deleted, not disabled. update_or_create never writes enabled. A row disabled by mistake would stay disabled through every later restart, and that task would be silently dead. A row deleted by mistake is recreated from settings at the next start.
  • The enabled flag is never touched. Unticking Enabled in the admin keeps working as the emergency switch that needs no deploy.
  • An empty schedule prunes nothing. If CELERY_BEAT_SCHEDULE comes back empty, settings almost certainly failed to load. Taken literally, an empty schedule would delete every row and stop everything, so the package logs a warning and leaves the table alone.
  • Celery's own celery.backend_cleanup is kept. Beat recreates it at every start anyway.
  • One-off tasks are kept by default. Rows with one_off=True are normally created from code for a single run and were never meant to be in settings.
  • A pruned task can't fire one last time. It is also dropped from the schedule the running Beat already holds, so it can't fire before Beat next re-reads the table.

Tasks created in the admin

If you also create periodic tasks by hand or from code, protect them by name or by shell-style pattern:

CELERY_BEAT_PRUNE_KEEP = ["manual-*", "nightly-export"]

Options

Setting Default Meaning
CELERY_BEAT_PRUNE_KEEP () Names or patterns (fnmatch) never removed
CELERY_BEAT_PRUNE_DRY_RUN False Log what would be removed, remove nothing
CELERY_BEAT_PRUNE_ONE_OFF False Also remove one_off=True rows

These are read from your Celery config (beat_prune_keep, and so on) or, failing that, from the Django settings above.

Look before you prune

The first time, see what would go without restarting Beat:

python manage.py prune_periodic_tasks --dry-run
python manage.py prune_periodic_tasks --keep "manual-*"

The command needs your Celery app to be imported, which it is in the usual layout (from .celery import app as celery_app in your project's __init__.py).

Using the function directly

from django_celery_beat_prune import prune, Options

result = prune(app, Options(keep=("manual-*",), dry_run=True))
print(result.removed)

Why this exists

We run TheLoops, which streams pre-recorded video to YouTube, Twitch and other platforms around the clock, and its periodic work runs on Celery Beat. We once commented a task out of settings because it made about 10,000 useless API calls a day. When we later moved Beat's schedule into the database, we noticed that on a plain DatabaseScheduler that fix would have changed nothing. This package is the scheduler we wrote then. The background is in our engineering notes.

License

MIT

Metadata

Release files for django-celery-beat-prune 1.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-celery-beat-prune 1.0.0
File Size Uploaded Provenance Actions
django_celery_beat_prune-1.0.0.tar.gz 12.3 kB With provenance Details for django_celery_beat_prune-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-celery-beat-prune 1.0.0
File Interpreter ABI Platform Actions
django_celery_beat_prune-1.0.0-py3-none-any.whl Python 3 none any Details for django_celery_beat_prune-1.0.0-py3-none-any.whl

Total release size: 21.5 kB

Release files / django_celery_beat_prune-1.0.0.tar.gz

Download URL django_celery_beat_prune-1.0.0.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
283c89252f845eb8b067da38fbee6d20c27b5a788ad4ff8765928714dc97b856
BLAKE2b-256 checksum
How to use checksums
0ad826380acb636ce154ab1e80a56cb852e8d60ad9fc3422cf1b678d2c9e57f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Release files / django_celery_beat_prune-1.0.0-py3-none-any.whl

Download URL django_celery_beat_prune-1.0.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42fab7ee9b7d9623ba1a474e7bbd076504e73cdf63f5aeb7cae4ce2d716209d3
BLAKE2b-256 checksum
How to use checksums
bfb372c597cc51ebb8030ef2575bb2cfaf3e1f935e9b924ae1c7ec0ac559ff8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Security for django-celery-beat-prune 1.0.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_celery_beat_prune-1.0.0.tar.gz

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 Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

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