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.
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
| Character | Meaning | Example |
|---|---|---|
* | Any value | * * * * * = every minute |
, | List of values | 1,15 * * * * = minute 1 and 15 |
- | Range | 1-5 * * * * = minutes 1 through 5 |
/ | Step | */5 * * * * = every 5 minutes |
Common Cron Schedules
| Schedule | Expression | Description |
|---|---|---|
| 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 hour | 0 * * * * | At minute 0 of every hour |
| Every 2 hours | 0 */2 * * * | At minute 0, every 2 hours |
| Every day at midnight | 0 0 * * * | Once per day at 00:00 |
| Every day at noon | 0 12 * * * | Once per day at 12:00 |
| Every day at 9am | 0 9 * * * | Once per day at 09:00 |
| Every Monday at 9am | 0 9 * * 1 | Weekly on Monday |
| Weekdays at 9am | 0 9 * * 1-5 | Mon-Fri at 09:00 |
| Weekends at 10am | 0 10 * * 0,6 | Sat-Sun at 10:00 |
| First of month | 0 0 1 * * | Monthly at midnight |
| Every quarter | 0 0 1 1,4,7,10 * | Jan, Apr, Jul, Oct 1st |
| Every Sunday at 3am | 0 3 * * 0 | Weekly 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
-
Forgetting timezone — Cron typically runs in the server's timezone. Always specify or document which timezone your cron uses.
-
Overlapping executions — If a job takes 10 minutes but runs every 5 minutes, you'll have overlapping instances. Use a lock mechanism.
-
Day of month + day of week — When both are set, most cron implementations run on EITHER matching day (OR logic, not AND).
-
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 Expression Generator — Build cron expressions visually
- Unix Timestamp Converter — Convert timestamps for scheduling
- JSON Formatter — Format configuration files
- Chmod Calculator — Set permissions on cron scripts