Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of H/5 in cron Jenkins

Tags:

I have a job with as cron:

5 3,21 * * 1-5 

This will run my job at 03:05AM and 09:05PM. Now I read it's a best practice to use H.

I try:

H/5 3,21 * * 1-5 

What is the meaning now? Will this schedule a build in a range of 5 minutes or 5 minutes after 3AM and 21PM?

like image 456
DenCowboy Avatar asked Nov 15 '17 08:11

DenCowboy


People also ask

What is H in Jenkins cron?

'H' is used in the Jenkins continuous integration system to indicate that a "hashed" value is substituted. Thus instead of '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.

What does 0 * * * * mean in crontab?

0 * * * * -this means the cron will run always when the minutes are 0 (so hourly) 0 1 * * * - this means the cron will run always at 1 o'clock. * 1 * * * - this means the cron will run each minute when the hour is 1.

What is cron syntax in Jenkins?

Syntactically, CRON contains 5 places for each time entry, thus a conventional one-liner syntax of the CRON template would be somehow like: Copy Code. 0 23 * * * // Staged as {Minute} {Hour} {DayOfMonth} {Month} {DayofWeek} Minute (0-59) – tells at what minute of the hour the Job should build.

What is * in cron job?

Asterisk (*).Use this operator to signify all possible values in a field. For example, if you want your cron job to run every minute, write an asterisk in the Minute field.


1 Answers

The H will take a numeric hash of the Job name and use this to ensure that different jobs with the same cron settings do not all trigger at the same time.

H/5 in the first field means Every five minutes starting at some time between 0 and 4 minutes past the hour

So H/5 3,21 * * 1-5

is Every five minutes between 03:00 and 03:59 and then between 21:00 and 21:59 on Mon -> Fri but starting at some 'random' time between 03:00 and 03:04 and then the same number of minutes after 21:00

If you want to run once per hour between 03:00-03:59 and 21:00-21:59 on Mon -> Fri, you can use H 3,21 * * 1-5 where H will be replaced by some number between 0-59 depending on job name.

The user interface will tell you when the job will last have triggered and will next trigger

like image 182
Spangen Avatar answered Oct 31 '22 19:10

Spangen