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-crontabVerified import paths — ran on the pinned version, not inferred.
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`.
Consider alternative scheduling libraries like `django-apscheduler` or `django-cron` for modern Django projects, or be prepared to fork and maintain `django-crontab` yourself.
Always execute `python manage.py crontab add` after any change to your `CRONJOBS` list. To remove all jobs, use `python manage.py crontab remove`.
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.
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.