Utility library to convert Hashed Crons, using 'H' character.
Project description
hashed-cron
Description
Hashed-cron is a library that aim to create a better scheduler in your jobs, minimizing parallel execution in your compute resources.
responsible for converting crons that's use a feature coined by Jenkins called Hash.
According to Jenkins documentation:
To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources. The H symbol can be used with a range. For example, H H(0–7) * * * means some time between 12:00 AM (midnight) to 7:59 AM. You can also use step intervals with H, with or without ranges. The H symbol can be thought of as a random value over a range, but it actually is a hash of the job name, not a random function, so that the value remains stable for any given project.
Source: https://www.jenkins.io/doc/book/pipeline/syntax/
Installation
pip install hashed-cron
Usage
from hashed_cron import cron_converter
cron = "H H * * *"
converted_cron = cron_converter.convert(cron, "job_01")
print(converted_cron)
# Result: 41 5 * * *
Examples
Hashed Cron | Identifier | Result |
---|---|---|
H * * * * | job_01 | 41 * * * * |
H H * * * | job_01 | 41 5 * * * |
H * * * * | job_02 | 16 * * * * |
H H * * * | job_02 | 16 4 * * * |
H/30 * * * * | job_02 | 16/30 * * * * |
H/10 H/3 * * * | job_02 | 6/10 1/3 * * * |
H/10 H/3 0/2 * * | job_02 | 6/10 1/3 0/2 * * |
Bugs
If you find any bug, please add an issue on https://github.com/thiagowig/hashed-cron/issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file hashed-cron-0.1.0.tar.gz
.
File metadata
- Download URL: hashed-cron-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5711df0c3ff80a6d4f523563d58b9a3d36224a90d79384df895d2d2b66deead |
|
MD5 | 7209c0eb8d4d30786eb0c5da8801492f |
|
BLAKE2b-256 | 7320f58a75f28ba273d5c889c965904cf430275411b3543b4ee82f904197a82c |