DTTooleras

Cron Expressions Explained: Syntax, Examples, and Common Schedules

A practical guide to cron expressions — the syntax, every field explained, common scheduling patterns, and how to build complex schedules for cron jobs, GitHub Actions, and cloud functions.

DevToolsHub Team16 min read714 words

What is a Cron Expression?

A cron expression is a string of five (or six) fields that defines a schedule for recurring tasks. Originally from Unix cron jobs, the format is now used everywhere: GitHub Actions, AWS CloudWatch, Kubernetes CronJobs, CI/CD pipelines, and task schedulers.

Cron Syntax

A standard cron expression has five fields:

┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-7, 0 and 7 = Sunday)
│ │ │ │ │
* * * * *

Special Characters

CharacterMeaningExample
*Any value* * * * * = every minute
,List of values1,15 * * * * = minute 1 and 15
-Range1-5 * * * * = minutes 1 through 5
/Step*/5 * * * * = every 5 minutes

Common Cron Schedules

ScheduleExpressionDescription
Every minute* * * * *Runs 1,440 times/day
Every 5 minutes*/5 * * * *Runs 288 times/day
Every 15 minutes*/15 * * * *Runs 96 times/day
Every 30 minutes*/30 * * * *Runs 48 times/day
Every hour0 * * * *At minute 0 of every hour
Every 2 hours0 */2 * * *At minute 0, every 2 hours
Every day at midnight0 0 * * *Once per day at 00:00
Every day at noon0 12 * * *Once per day at 12:00
Every day at 9am0 9 * * *Once per day at 09:00
Every Monday at 9am0 9 * * 1Weekly on Monday
Weekdays at 9am0 9 * * 1-5Mon-Fri at 09:00
Weekends at 10am0 10 * * 0,6Sat-Sun at 10:00
First of month0 0 1 * *Monthly at midnight
Every quarter0 0 1 1,4,7,10 *Jan, Apr, Jul, Oct 1st
Every Sunday at 3am0 3 * * 0Weekly maintenance window

Real-World Examples

GitHub Actions

name: Daily Build
on:
  schedule:
    - cron: "0 6 * * *"  # Every day at 6am UTC

Kubernetes CronJob

apiVersion: batch/v1
kind: CronJob
metadata:
  name: backup
spec:
  schedule: "0 2 * * *"  # Every day at 2am
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: backup
            image: backup-tool:latest

Node.js (node-cron)

const cron = require("node-cron");

// Every 5 minutes
cron.schedule("*/5 * * * *", () => {
  console.log("Running health check...");
});

// Every weekday at 9am
cron.schedule("0 9 * * 1-5", () => {
  sendDailyReport();
});

Linux Crontab

# Edit crontab
crontab -e

# Add entries
*/5 * * * * /usr/bin/health-check.sh
0 2 * * * /usr/bin/backup.sh
0 9 * * 1-5 /usr/bin/send-report.sh

# List current crontab
crontab -l

Common Mistakes

  1. Forgetting timezone — Cron typically runs in the server's timezone. Always specify or document which timezone your cron uses.

  2. Overlapping executions — If a job takes 10 minutes but runs every 5 minutes, you'll have overlapping instances. Use a lock mechanism.

  3. Day of month + day of week — When both are set, most cron implementations run on EITHER matching day (OR logic, not AND).

  4. Month/day starting at 1 — Minutes and hours start at 0, but months and days start at 1.

Build and validate your cron expressions with our Cron Expression Generator — it shows human-readable descriptions and next execution times.

Related Tools

cron expressioncron jobcron syntaxcron schedulecrontabcron examplesgithub actions cron

Related articles

All articles

Practice with free tools

200+ free developer tools that run in your browser.

Browse all tools →