Jenkins cron syntax, with examples
Jenkins schedules jobs with a crontab-style expression in the Build periodically and Poll SCM triggers. It uses the same five fields as Unix cron (minute, hour, day of month, month, day of week) but adds the H hash symbol, a TZ= line for time zones, and one rule that differs from standard cron. To run a job once a day, use H H * * *.
The H symbol
Hstands for “hash”. In place of a fixed value, Jenkins picks one from a hash of the job's name, so each job gets its own stable offset. A dozen jobs set to 0 0 * * * all start at midnight and spike the controller; the same jobs set to H H * * * still run once a day each, but spread across the day. The value is not random: a given job runs at the same time every day.
H works with ranges and steps. H(0-7) in the hour field picks an hour from 0 to 7, and H/15 in the minute field runs every 15 minutes starting from a per-job offset. When you save a schedule such as */15 * * * * or 0 2 * * *, Jenkins shows a warning suggesting the H form instead. The plain form still works; the warning is only about load.
Jenkins cron examples
H/15 * * * *Every 15 minutes, at a fixed offset per job (perhaps :07, :22, :37, :52)H * * * *Once an hour, at a minute chosen per jobH H * * *Once a day, at a time chosen per jobH 2 * * *Once a day during the 2 AM hourH H(0-7) * * *Once a day, some time between midnight and 7:59 AMH(0-29)/10 * * * *Every 10 minutes in the first half of each hour (three runs, perhaps :04, :14, :24)H H(8-15)/2 * * 1-5Once in every two-hour slot between 8 AM and 4 PM, Monday to Friday45 9-16/2 * * 1-5At 9:45, 11:45, 13:45 and 15:45, Monday to FridayH H 1,15 1-11 *Once a day on the 1st and 15th of every month except December
Aliases: @daily, @midnight and the rest
Jenkins accepts these shortcuts, and every one of them is hashed. That surprises people coming from Unix cron, where @daily means exactly midnight: in Jenkins, @midnightmeans some time between 12:00 and 2:59 AM. Jenkins doesn't support @reboot.
| Alias | Same as | Runs |
|---|---|---|
| @hourly | H * * * * | Once an hour, at any minute |
| @daily | H H * * * | Once a day, at any time |
| @midnight | H H(0-2) * * * | Once a day between 12:00 AM and 2:59 AM |
| @weekly | H H * * H | Once a week, on any day |
| @monthly | H H H * * | Once a month, on a day from the 1st to the 28th |
| @yearly / @annually | H H H H * | Once a year |
Day of month and day of week both have to match
In standard cron, when both day fields are restricted, the job runs when either matches. Jenkins requires both. H 9 1-7 * 1 runs only on the first Monday of each month in Jenkins, while crontab would run it on the 1st to the 7th and on every Monday. Day of week accepts 0 to 7, and both 0 and 7 mean Sunday.
Time zones with TZ=
Schedules run in the time zone of the Jenkins controller's JVM. To use another zone, put TZ= and a Java time zone ID on the first line. Lines starting with # are comments, and each further line is another schedule:
TZ=Europe/London # Every weekday morning, London time H 8 * * 1-5 # And once more in the evening H(0-30) 17 * * 1-5
Cron triggers in a Jenkinsfile
In a declarative pipeline, the same expressions go in a triggers block. cron builds on schedule; pollSCM checks the repository on schedule and builds only when something changed.
pipeline {
agent any
triggers {
cron('H 2 * * 1-5')
// or: pollSCM('H/15 * * * *')
}
stages {
stage('Build') {
steps {
echo 'Nightly build'
}
}
}
}Jenkins registers the trigger when the pipeline runs, so a new or changed schedule takes effect only after the job has run once with it.
Need the field-by-field basics first? See the cron expression syntax guide.