quartz-scheduler / quartz

Code for Quartz Scheduler
http://www.quartz-scheduler.org
Apache License 2.0
6.23k stars 1.92k forks source link

Random startup time using cron expressions #1074

Open a1kaigorodov opened 11 months ago

a1kaigorodov commented 11 months ago

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 commented 9 months ago

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