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

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.

AliasSame asRuns
@hourlyH * * * *Once an hour, at any minute
@dailyH H * * *Once a day, at any time
@midnightH H(0-2) * * *Once a day between 12:00 AM and 2:59 AM
@weeklyH H * * HOnce a week, on any day
@monthlyH H H * *Once a month, on a day from the 1st to the 28th
@yearly / @annuallyH 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.