Registry / workflow / django-crontab

django-crontab

JSON →
library0.7.1pypypiunverified

django-crontab is a Python library providing dead-simple job scheduling for Django applications, leveraging the system's `crontab` utility. The latest version is 0.7.1, released in March 2016. Due to its age and lack of recent updates, it is best suited for legacy Django projects (up to Django 2.0) or users prepared to address potential issues themselves.

pip install django-crontab
INSTALL
IMPORT
SIG · DJANGO-CRONTAB
D
django-crontab
workflowpythonv0.7.1
Install
4.4s avg
Import
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 67.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 4.4s · import 0.000s · 68MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CRONJOBS (setting)
CRONJOBS = [('*/5 * * * *', 'myapp.cron.my_scheduled_job')]
Configuration is primarily done via the CRONJOBS setting in settings.py, pointing to a Python callable, rather than direct module imports for scheduling logic.

To quickly set up `django-crontab`, first add `django_crontab` to your `INSTALLED_APPS`. Then, define your scheduled functions within a Python file (e.g., `myapp/cron.py`). Finally, specify these jobs in your `settings.py` using the `CRONJOBS` list, and activate them by running `python manage.py crontab add`. Remember to run `crontab add` after any changes to `CRONJOBS`.

import os # settings.py INSTALLED_APPS = [ # ... 'django_crontab', 'myapp', # Your app containing the cron job ] CRONJOBS = [ # Run 'myapp.cron.my_scheduled_job' every 5 minutes ('*/5 * * * *', 'myapp.cron.my_scheduled_job'), # Example calling a Django management command daily at midnight ('0 0 * * *', 'django.core.management.call_command', ['clearsessions']), # Example with arguments and redirecting output to a log file ('0 0 * * 0', 'django.core.management.call_command', ['dumpdata', 'auth'], {'indent': 4}, f'> {os.environ.get('DJANGO_CRON_LOG_DIR', '/tmp')}/last_sunday_auth_backup.json'), ] # myapp/cron.py # Create this file in your Django app def my_scheduled_job(): # Your periodic task logic goes here print('My scheduled job ran!') # Example: Log to a file or database with open(f'{os.environ.get('DJANGO_CRON_LOG_DIR', '/tmp')}/django_crontab_log.txt', 'a') as f: f.write('Job executed at ' + str(os.time.time()) + '\n') # After configuring, run in your terminal: # python manage.py crontab add # To view jobs: # python manage.py crontab show # To remove jobs: # python manage.py crontab remove
Debug
Known issues
breakingThe project is effectively abandoned, with the last release in March 2016. This means critical bugs, security vulnerabilities, or incompatibilities with newer Python/Django versions (beyond Django 2.0) are unlikely to be addressed.
fix
Consider alternative scheduling libraries like `django-apscheduler` or `django-cron` for modern Django projects, or be prepared to fork and maintain `django-crontab` yourself.
affects: 0.7.1 and older
gotchaYou MUST run `python manage.py crontab add` every time you modify the `CRONJOBS` setting in your `settings.py`. Forgetting this step is a very common reason why scheduled tasks do not run as expected.
fix
Always execute `python manage.py crontab add` after any change to your `CRONJOBS` list. To remove all jobs, use `python manage.py crontab remove`.
affects: All versions
gotchaThe library does not work on Windows operating systems, as it relies on the underlying Unix `crontab` utility.
fix
Deploy your Django application to a Linux-based environment (e.g., Docker container, VPS) for `django-crontab` to function correctly. Consider Windows-compatible task schedulers or alternative Django-based solutions for Windows development.
affects: All versions
gotchaWhen running in Docker or other containerized environments, the cron daemon might not be running by default, or the Python executable path might be incorrect. This can lead to jobs being 'added' but never executing.
fix
Ensure the `cron` service is started within your Docker container's entrypoint or `CMD` (e.g., `service cron start && tail -f /var/log/cron.log`). Verify that the Python executable used by cron (often `/usr/local/bin/python` in containers) matches your environment.
affects: All versions
Upgrade
Version history
0.7.1latest on PyPI · released Mar 7, 2016
Audit
Dependencies
DjangorequiredThe library explicitly states compatibility with Django 1.8-2.0. Newer Django versions may have compatibility issues due to the lack of updates.
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
django-crontab — pip install django-crontab · libregistry