Skip to main content
Error Code Decoders & Troubleshooting

Jenkins Crontab Syntax: CLI Reference & Troubleshooting

jenkins crontab is a scheduling syntax extending standard cron with the H (hash) symbol, used in Jenkins job configuration and Pipeline triggers to distribute execution load across time.

# Every fifteen minutes (e.g., :07, :22, :37, :52)
H/15 * * * *
# Every ten minutes in the first half of each hour
H(0-29)/10 * * * *
# Every two hours weekdays, 9:45 AM to 3:45 PM
45 9-16/2 * * 1-5

Jenkins cron expressions are defined in job configuration or Pipeline triggers directives. Use H to avoid simultaneous job starts, especially in large deployments. Each field supports numbers, *, /, -, ,, and H with optional ranges.

Jenkins Crontab Rapid Reference Cheat Sheet

Action Jenkins Cron Expression Standard Cron Equivalent Key Difference
Run every 15 minutes H/15 * * * * */15 * * * * H/15 distributes the offset across jobs; */15 runs at fixed minute (e.g., :00, :15, :30).
Run every 2 hours starting at 9:45 AM weekdays 45 9-16/2 * * 1-5 Same No H — fixe8d schedule. Safe when load is not a concern.
Run daily at midnight with load distribution H H * * * 0 0 * * * H H picks a random minute and hour per job; avoids thundering herd.
Run at 12:00, 12:10, 12:20 in first half-hour H(0-29)/10 * * * * 0/10 * * * * (would be :00, :10, :20, :30, …) H(0-29)/10 only triggers in minute range 0–29, effectively 3 runs per hour.
Trigger on every weekday at 8:00 AM and 5:00 PM 0 8,17 * * 1-5 Same No H. Use when exact time is required (e.g., dependent jobs).
See also  Linux mv Command Reference – Syntax, Exit Codes, Troubleshooting

Advanced Implementation

Declarative Pipeline Triggers

pipeline {
    agent any
    triggers {
        cron('H/30 * * * *')
    }
    stages {
        stage('Build') {
            steps {
                echo 'Scheduled build triggered'
            }
        }
    }
}

The H (Hash) Symbol

H is replaced at job run-time with a deterministic hash of the job name, producing a unique minute/hour offset per job. This prevents dozens of jobs configured with H * * * * from firing at the same second. The hash changes if the job is renamed; use fixed expressions for time-critical schedules.

Environment Variables and Parameters

Parameterized schedules require the cron string to be resolved at Pipeline load time. Example:

pipeline {
    parameters {
        string(name: 'RUN_AT', defaultValue: 'H/15 * * * *')
    }
    triggers {
        cron("${params.RUN_AT}")
    }
    stages {
        stage('Build') {
            steps {
                echo "Running with schedule ${params.RUN_AT}"
            }
        }
    }
}

Error Resolution & Troubleshooting

Error / Symptom Root Cause Remediation
Job never triggers Time zone mismatch, or incorrect field value (e.g., using 0-59 out of range, or 7 for DOW). Verify Jenkins master timezone (-Duser.timezone=UTC). Check cron expression in triggers block. Use */2 instead of 2 to mean every 2.
Jobs run all at the same second All jobs use fixed cron expressions like 0 * * * * without H. Replace with H * * * * or H(0-59)/1 * * * * to distribute.
Invalid input error in job config Unsupported characters: @, L, W, # (standard cron extensions not supported). Use only numbers, *, /, -, ,, and H with parentheses.
Job runs once but not again Trigger misconfiguration (e.g., 0 0 1 1 * runs only on Jan 1). Review expression with crontab.guru (note: Jenkins H is not supported there). Use Cron Column plugin to verify.
H evaluates to a time outside expected window Hash may produce unexpected offsets for very small ranges. Test with multiple runs: check console output for “[Schedule] using hash…” message. Use explicit H(0-29) to enforce range.
See also  linux show processes: ps command reference with examples

Production-Grade Implementation

Spread Load Across Time

In production environments with 100+ scheduled jobs, always use H in the minute field. For multi-node Jenkins clusters, the hash ensures each job settles on a consistent runner time regardless of node.

Combine with pollSCM for Source Monitoring

triggers {
    pollSCM('H/5 * * * *')  // check SCM every 5 minutes, with hash
    cron('H 2 * * 1-5')    // nightly build at a unique 2am weekday time
}

Avoid Using Fixed Minutes for Large Job Sets

If you must use a fixed minute (e.g., 0 * * * *), limit to fewer than 10 jobs to prevent resource contention. For larger sets, wrap in stage('Reserve') { lock(resource: 'cron-slot') } to serialize.

Testing Cron Expressions

Jenkins does not provide a dry-run simulator. Use the built-in “Polling Log” after triggering SCM polling, or rely on the Cron Column plugin to verify recent fire times.

Frequently Asked Questions

What is the difference between standard cron and Jenkins cron?

Jenkins cron uses H for hash-based scheduling to spread load and avoid concurrent triggers, while standard cron uses fixed times. Example: H * * * * runs every hour at a job-specific minute, whereas 0 * * * * runs at minute 0.

When should I use the H symbol?

Use H in any field to distribute execution times across the schedule period. For non-precision triggers, always use H to avoid resource contention. Example: triggers { cron('H */4 * * *') }.

How do I fix “Invalid cron expression” errors?

Remove unsupported macros (@reboot, L, W), replace */1 with H, and ensure no trailing whitespace. Use the Pipeline Syntax tool to validate.

What is the fastest way to trigger a job every 5 minutes?

Use H/5 * * * * in triggers. For exact intervals, use 0 */5 * * * but risk concurrency. Example pipeline: triggers { cron('H/5 * * * *') }.