A Django app to define routines that should run periodically
Project description
Django Schedules
This app allows you to define routines that should run periodically (e.g. every day at 0:00, ...). They will be triggered by systemd-timers or cron.
Define Routines
- Add "schedules" to your
INSTALLED_APPSsetting. - Add a file called
schedules.pyto your django app. - Define functions in this file.
- Each function which is a timer job should be decorated by the
registerdecorater:
Example:
import django_schedules
@django_schedules.register(mins=0, hour=0)
def run_at_midnight(**kwargs):
print('hello')
@django_schedules.register(mins=3, hour=18, day_of_month=2, month='5,11', lock=False, job_name='foobar')
def bar(**kwargs):
"""
Run on 2.5. and 2.11. at 18:03.
Don't use locking (allow to run this job more than once at the same time).
The job will be called 'foobar'.'
"""
print('hello')
Commands
Now you can use following management commands:
./manage.py schedules_list # list all available jobs
./manage.py schedules_update_systemd [-u user] [--out-path path] # generate systemd units (for user 'user' (default root))
./manage.py schedules_update_cron [-u user] [-o file] # generate crontab "code" (for user 'user' (default root)) (and write it to file file)
./manage.py schedules_run [<app_name>:]<job_name> [additional_args, ...] # run the job app_name:job_name
Installation
- Write your code (see above)
- Run
./manage.py schedules_listto verify all jobs are registered as expected - Run
./manage.py schedules_update_systemd -u $DJANGO_USER [--out-path /etc/systemd/system/]to generate systemd units - Or run
./manage.py schedules_update_cron -u $DJANGO_USER -o /etc/cron.d/$DJANGO_PROJECT_NAMEto let the jobs run by system cron
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_schedules-1.1.2.tar.gz
(42.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_schedules-1.1.2.tar.gz.
File metadata
- Download URL: django_schedules-1.1.2.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5107d2003466b669ef8aa67317860c2a76cf253a940af9c829114493a7f4b09a
|
|
| MD5 |
9fe7b2e26d835df3ad22c36508969b29
|
|
| BLAKE2b-256 |
ca5af6f59cc8e4b5d2c48d72f691125378c8811f57e0d443694c7e7e7656a071
|
File details
Details for the file django_schedules-1.1.2-py3-none-any.whl.
File metadata
- Download URL: django_schedules-1.1.2-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be339eb9565a6577ce5085cbc3d3f91cf44b91eb6114eab442e887d87574ffb3
|
|
| MD5 |
eb0088683c9035788a2aa3f58e5076fb
|
|
| BLAKE2b-256 |
93cb60afda45cb43f43e6661a7aa6329de3df9427c7731b8db99af4224e6c417
|