🔧 Jenkins cron, decoded.
Jenkins extends 5-field cron with the unique H (hash) operator. H/15 means "every 15 minutes, but at a hashed offset": useful when many jobs share the same trigger frequency to avoid simultaneous load spikes.
Jenkins Generator
H resolver: see the minutes Jenkins picks
Jenkins turns each H into a fixed value computed from the job's full name. Enter the name exactly as Jenkins knows it and the schedule from your cron('…') trigger or the "Build periodically" box. The result is what Jenkins itself calculates.
Folders and job joined by /: …/job/team/job/backend-nightly/ in the URL is team/backend-nightly. Use the job's name, not its display name.
The exact algorithm, from the Jenkins source.
- Jenkins takes the job's full name (for example
team/backend-nightly), hashes its UTF-8 bytes with MD5, XORs the last 8 bytes of the digest onto the first 8, and uses the result as the seed of ajava.util.Random(hudson.scheduler.Hash). - Reading the schedule from left to right, every
Hasks that random generator for the next number. PlainHpicks one value in the field;H/15picks a start from 0-14 and then every 15th value;H(0-29)/15picks a start from 0-14 and keeps only the values up to 29, so it runs twice an hour, not four times. - In the day-of-month field
Honly picks days 1-28, and in the day-of-week field 0-6, so the job never lands on a day that some months don't have. - All lines of a schedule share one generator, so the
Hvalues on line 2 depend on how manyHs line 1 used. Reordering lines changes the times. @hourly,@daily,@weekly,@monthlyand@yearlyare hashed too (@daily=H H * * *, so it can run at any hour, not at midnight).@midnightisH H(0-2) * * *: somewhere between 00:00 and 02:59.
Consequences: renaming or moving a job into a folder changes its times; two jobs with the same schedule but different names run at different minutes, which is the point; and Jenkins requires day-of-month and day-of-week to match (unlike Unix cron, which runs when either matches).
One quirk: TZ= is ignored for @keywords
A schedule can start with a line such as TZ=Europe/London. But when Jenkins expands an @daily-style keyword, it re-parses the line without the time zone, so @daily under TZ=… runs in the controller's own time zone. Write H H * * * instead of @daily if the time zone matters. The resolver above shows this.
How this resolver was checked
It is a port of Hash.java, BaseParser.java, the CrontabParser.g4 grammar and CronTabList.create() from Jenkins core 2.580.2 (the current LTS). We compared it with the real jenkins-core-2.580.2.jar on 8,000 generated schedules: single and multi-line, with TZ= lines, every @keyword, folder names and non-ASCII job names: it accepted and rejected the same schedules and produced identical minute, hour, day, month and weekday bits for every accepted one.
Sources: Jenkins core 2.580.2: Hash.java, BaseParser.java, CrontabParser.g4, CronTabList.java, Trigger.java (seed = Hash.from(job.getFullName())).
Common Jenkins schedules.
| Expression | What it means | Typical use |
|---|---|---|
H/5 * * * * |
Every 5 minutes (hashed offset) | Spread load across multiple jobs. |
H/15 * * * * |
Every 15 minutes (hashed offset) | Recommended for polling-heavy systems. |
H * * * * |
Hourly at a hashed minute | Avoid stampede at :00. |
H H * * * |
Daily at a hashed time | Off-hours batch jobs. |
H 9 * * 1-5 |
Weekdays ~9 AM (hashed minute) | Business-hours triggers. |
H H * * 0 |
Sundays at hashed time | Weekly maintenance. |
Click any expression to load it into the tool above.
Where the cron schedule goes in Jenkins.
Freestyle jobs: Build periodically
Open the job, click Configure, and under Build Triggers tick Build periodically. Type the schedule into the Schedule box; Jenkins shows the previous and next run times under it. Poll SCM takes exactly the same syntax, but only starts a build when the repository has changed.
Pipeline jobs: triggers { cron(...) }
pipeline {
agent any
triggers {
cron('H */4 * * 1-5') // every 4 hours, Monday to Friday
// pollSCM('H/15 * * * *') // or: check for changes every 15 minutes
}
stages {
stage('Build') { steps { echo 'Hello' } }
}
}
The declarative triggers directive accepts cron, pollSCM and upstream.
The rules of the Schedule box
- Five fields:
MINUTE HOUR DOM MONTH DOW. Minute 0-59, hour 0-23, day of month 1-31, month 1-12, day of week 0-7 (0 and 7 are Sunday). - One schedule per line; the job runs when any line matches. Empty lines and lines starting with
#are comments. - An optional first line
TZ=Europe/Londonsets the time zone; otherwise Jenkins uses the controller's zone. @yearly,@annually,@monthly,@weekly,@daily,@midnightand@hourlywork, but they are hashed:@hourlyisH * * * *, and@midnightmeans some time between 12:00 and 2:59 AM.- Jenkins' own help says Build periodically is mainly for using Jenkins as a cron replacement. For continuous integration, trigger builds from your repository's change notifications instead.
Examples from the Jenkins documentation
| Schedule | What it does |
|---|---|
H/15 * * * * | Every fifteen minutes (perhaps at :07, :22, :37, :52) |
H(0-29)/10 * * * * | Every ten minutes in the first half of every hour (three times, perhaps at :04, :14, :24) |
45 9-16/2 * * 1-5 | Every two hours at 45 past, 9:45 AM to 3:45 PM, every weekday |
H H(8-15)/2 * * 1-5 | Once in every two-hour slot between 8 AM and 4 PM on weekdays (perhaps 9:38, 11:38, 1:38, 3:38) |
H H 1,15 1-11 * | Once a day on the 1st and 15th of every month except December |
Paste any of them into the resolver above with your job's name to see the exact minutes Jenkins will pick. One more warning from the Jenkins help: short day-of-month steps such as H/3 are uneven at the end of the month, because H only picks days 1-28.
Sources: Jenkins core TimerTrigger help (the text behind the Schedule box) and Pipeline syntax: triggers.
Jenkins FAQs.
H replaces a fixed value with one computed from the job's hash. So H/15 * * * * in Job A might run at :07, :22, :37, :52 while Job B runs at :03, :18, :33, :48. Both run every 15 minutes, but they don't collide.
Two reasons: (1) Load distribution, if 100 jobs all trigger at 0 * * * *, the master is overwhelmed at :00. With H, they spread across the hour. (2) Jenkins itself suggests it: its schedule check warns "Spread load evenly by using ‘H …’ rather than ‘…’" for fixed minutes.
Yes: H(0-29)/15 picks a start minute from 0-14 from the job's hash and keeps only the minutes up to 29, so it runs twice an hour (for example at :07 and :22), not four times. Use it to keep a job inside a window.
It hashes the job's full name. So Job "build-frontend" always gets the same offset, and Job "build-backend" gets a different one. Renaming a job changes its hashed schedule.
Yes: H H * * H runs once a week on a weekday and at a time picked from the job's hash. It is not random from week to week: the same job always gets the same day and time, and H in the weekday field only picks 0-6.
In a freestyle job: Configure → Build Triggers → Build periodically, then enter the schedule. In a Pipeline, add triggers { cron('H 2 * * *') } to the Jenkinsfile. See Build periodically above.
Five fields: minute (0-59), hour (0-23), day of month (1-31), month (1-12) and day of week (0-7, where 0 and 7 are Sunday). Jenkins adds H, a value picked from the job name, and supports @hourly, @daily, @weekly, @monthly and @yearly, which are hashed too.
Because the schedule uses H or an @ keyword. Jenkins replaces each H with a value computed from the job's full name, so H * * * * (or @hourly) runs once an hour at a minute that is fixed for that job but differs between jobs. Use the resolver on this page to see which minute your job gets.
Put TZ= and a time zone ID on the first line of the schedule, for example TZ=America/New_York, then the schedule on the next line. Note that @daily-style keywords ignore that line; write H H * * * instead.
Both use the same cron syntax. Build periodically starts a build every time the schedule matches. Poll SCM checks the repository on that schedule and only starts a build if something changed.