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_createnever writesenabled. 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
enabledflag 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_SCHEDULEcomes 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_cleanupis kept. Beat recreates it at every start anyway. - One-off tasks are kept by default. Rows with
one_off=Trueare 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)
| 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)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 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 logRelease 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 logSecurity 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.
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 logA 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.