cron "H" syntax

13,374 views
Skip to first unread message

Maven User

unread,
May 23, 2012, 5:08:37 PM5/23/12
to jenkins...@googlegroups.com
I just saw this and am kinda intrigued...

Currently, we have 30 - 40 jobs all configured as */5 * * * * (so every 5 min) for their polling interval.

But then I see this "H" thing....

"To allow periodically scheduled tasks to produce even load on the system, the 'H' token can be used. For example, people often use '0 0 * * *' for a daily job, but this ends up causing a large spike in midnight. In contrast, doing 'H H * * *' would still execute a job once a day, but the actual time of the day this gets executed will be spread over by Jenkins."

I won't allow me to do H/5 * * * * (so randomly every five minutes) and IIUC, if I have H * * * *, that would be once an hour, randomly.

Is there a way to use "H" in such a way that it will poll about every 5 min, but prevent every job from polling at the exact same time?

Kohsuke Kawaguchi

unread,
May 23, 2012, 6:09:39 PM5/23/12
to jenkins...@googlegroups.com
Thanks for an interesting use case.

*/5 is just a short hand for 0-60/5, so I guess the general case that
needs to be considered here is how to use hash in "(s-e)/d" construct.

What's the good syntax here? H(s-e)/d? H(*)/d vs H/d?


2012/5/23 Maven User <maven....@gmail.com>:
--
Kohsuke Kawaguchi

Maven User

unread,
May 23, 2012, 6:34:42 PM5/23/12
to jenkins...@googlegroups.com
"H" is a drop in for any of the time slots and/or *, so it felt natural (for me) to try "H/5".

To explain that in a different way, I was attempting to say "poll every 5 minutes if nothing is polling, wait for that to finish otherwise".

With that out there, if I just leave everything "*/5 * * * *", and wanted things to poll in isolation, couldn't I turn down the concurrent polling down to 1?

IIUC - with the "H" option, jenkins would decide how to split things up and I could leave the concurrent polling unbounded (which is a better option methinks).

I wonder if that would eventually prevent things from getting a chance to poll at all....

Walter Kacynski

unread,
Apr 1, 2013, 1:13:53 PM4/1/13
to jenkins...@googlegroups.com
Did you ever find a solution for using  "H/5"?  I'm facing the same issue that you describe.

Thanks.

Tom D'Aurizio

unread,
Apr 2, 2013, 12:29:02 PM4/2/13
to jenkins...@googlegroups.com
Here's what we use for random every 5 minutes.   We rolled this out extensively in our environments to avoid point loading SCM servers.  Making these changes really helped spread out the load on our source control servers. 

Random 5 minutes (I copied this, the syntax should be ok):
H(0-4),H(5-9),H(10-14),H(15-19),H(20-24),H(25-29),H(30-34),H(35-39),H(40-44),H(45-49),H(50-54),H(55-59) * * * *

Random 15 minutes (typed this, haven't checked the syntax)
H(0-14),H(15-29),H(30-44),H(45-59) * * * *

And moving from @daily to this:
H H(0-5) * * *

Geoff Cummings

unread,
Apr 2, 2013, 5:14:21 PM4/2/13
to jenkins...@googlegroups.com

Looks like there are improvements in this area coming in 1.510

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages