Skip to content

Conversation

@adampetrovic
Copy link

@adampetrovic adampetrovic commented Oct 22, 2024

This implements what is requested in #309

Some cron implementations use H as a hashed substitution for a value:

'H' is used in the Jenkins continuous integration system to indicate that a "hashed" value is substituted. Thus instead of a fixed number such as '20 * * * *' which means at 20 minutes after the hour every hour, 'H * * * *' indicates that the task is performed every hour at an unspecified but invariant time for each task. This allows spreading out tasks over time, rather than having all of them start at the same time and compete for resources.

This change extends the API without breaking backward compatibility by adding a ParseWithJobName function allowing the caller to provide a unique job name to perform the hashing.

The function supports the following expressions:

  • H: Uses the provided bounds as min/max with step of 1
  • H/n: Uses the provided bounds as min/max with step of n
  • H(min-max): Uses the specified range with step of 1
  • H(min-max)/n: Uses the specified range with step of n
parser := NewParser(SecondOptional | Minute | Hour | Dom | Month | Dow | Descriptor)
parser.ParseWithJobName("H(0-30)/10 * * * * *", "job2")
// results in a schedule that runs every minute at the 8, 18, 28 second mark.

@adampetrovic
Copy link
Author

@robfig any chance you're still accepting PRs on this project? It seems there hasn't been a commit in 4 years.

@tooptoop4
Copy link

dis abandonware ☠️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants