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.

This library is inspired in Jenkins Hash syntax. According to it's 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/

A blog post: https://medium.com/@dev.thiago/minimize-scheduled-concurrency-with-hashed-cron-library-25433c7760c4


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.4.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hashed_cron-0.4.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file hashed_cron-0.4.0.tar.gz.

File metadata

  • Download URL: hashed_cron-0.4.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for hashed_cron-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6dfee29f42989a4a6e30b35ec6dc14112df413cddfddc48236e4e85d6b1290ab
MD5 76b9f804347a14de5f436083e44407b8
BLAKE2b-256 80b8a472e0057af2696ac4c651a99adf0e6e6e165c29b938f2a6fa7609f48efc

See more details on using hashes here.

File details

Details for the file hashed_cron-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: hashed_cron-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for hashed_cron-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fbbaa46dc13eeb2b4174d39326828d7fff524eb63db3a1e18a5d9f12efa1fec
MD5 9761339c62aac38748c1d508bb2e0673
BLAKE2b-256 fca2a1dedc1f6fb82bf2c93c9bea9e70c1424223c7d84cb0b755cdbd5a1b0f6f

See more details on using hashes here.

Supported by

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