Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hashed-cron-0.1.0.tar.gz (2.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page