Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random startup time using cron expressions #1074

Open
a1kaigorodov opened this issue Oct 11, 2023 · 2 comments
Open

Random startup time using cron expressions #1074

a1kaigorodov opened this issue Oct 11, 2023 · 2 comments

Comments

@a1kaigorodov
Copy link

On OpenBSD, you can use the ~ symbol to specify random time values.

A random value (within the legal range) may be obtained by using the ‘~’ character in a field. The interval of the random value may be specified explicitly, for example “0~30” will result in a random value between 0 and 30 inclusive. If either (or both) of the numbers on either side of the ‘~’ are omitted, the appropriate limit (low or high) for the field will be used.

Step values can be used in conjunction with ranges. Following a range with /number specifies skips of number through the range. For example, “0–23/2” can be used in the hour field to specify command execution every other hour. Steps are also permitted after an asterisk, so to say “every two hours”, just use “*/2”. A step value after a random range will execute the command at a random offset less than the step size. For example, to avoid a thundering herd at the top and bottom of the hour, “0~59/30” (or simply “~/30”) can be used in the minute field to specify that command execution happen twice an hour at consistent intervals.

https://man.openbsd.org/crontab.5

It would be great if the scheduler could use such cron expressions.

@ecki
Copy link

ecki commented Dec 2, 2023

And also „h“ for a random but stable (hashed) value

@bcode2
Copy link
Contributor

bcode2 commented Nov 7, 2024

@jhouserizer @a1kaigorodov I have already implemented this (for seconds too). Let see if I have time tomorrow to add some tests and create the PR. Umm I have to update the docs and the changelog too I guess :)

bcode2 added a commit to bcode2/quartz that referenced this issue Nov 9, 2024
…ate random startup time using cron expressions

Signed-off-by: Carlos Garcia <[email protected]>
bcode2 added a commit to bcode2/quartz that referenced this issue Nov 9, 2024
…ate random startup time using cron expressions. Add tests.

Signed-off-by: Carlos Garcia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants