What is a Cron Expression?
A cron expression is a compact string used to define recurring schedules in Unix-like operating systems and modern DevOps tools. Originally created for the Unix cron daemon, cron expressions are now used everywhere — from Linux servers and cloud platforms (AWS, GCP, Azure) to CI/CD pipelines (GitHub Actions, GitLab CI, Jenkins) and application frameworks (Spring, Laravel, Node.js).
Instead of writing complex scheduling logic in code, you define a single string like 30 2 * * * to run a task every day at 2:30 AM. This simplicity makes cron expressions a universal standard for task automation.
Cron Syntax Explained
A standard cron expression consists of five fields separated by spaces. Each field controls a different aspect of the schedule:
| | | +------- Month (1-12)
| | +----------- Day of Month (1-31)
| +--------------- Hour (0-23)
+------------------- Minute (0-59)
Cron Fields Breakdown
| Field | Allowed Values | Special Characters | Example |
|---|---|---|---|
| Minute | 0-59 | * , - / | */15 = every 15 min |
| Hour | 0-23 | * , - / | 9 = 9 AM |
| Day of Month | 1-31 | * , - / | 1,15 = 1st & 15th |
| Month | 1-12 | * , - / | 1-6 = Jan to Jun |
| Day of Week | 0-6 (Sun=0) | * , - / | 1-5 = Mon to Fri |
Special Characters
* Asterisk (Every)
Matches all possible values for that field. * * * * * means every minute of every hour of every day.
/ Slash (Interval)
Defines step values. */10 in the minute field means every 10 minutes (0, 10, 20, 30, 40, 50).
, Comma (List)
Specifies multiple values. 1,3,5 in the day-of-week field means Monday, Wednesday, and Friday.
- Hyphen (Range)
Defines a range of values. 9-17 in the hour field means every hour from 9 AM to 5 PM.
Common Cron Schedule Examples
| Schedule | Expression | Description |
|---|---|---|
| Every minute | * * * * * | Runs once every minute, 24/7 |
| Every 5 minutes | */5 * * * * | Runs at minutes 0, 5, 10, 15, ..., 55 |
| Every hour | 0 * * * * | Runs at the start of every hour |
| Every day at midnight | 0 0 * * * | Runs once daily at 12:00 AM |
| Every Monday at 9 AM | 0 9 * * 1 | Runs weekly on Monday mornings |
| Weekdays at 8 AM | 0 8 * * 1-5 | Runs Monday through Friday at 8:00 AM |
| 1st of every month | 0 0 1 * * | Runs at midnight on the first day of each month |
| Every 6 hours | 0 */6 * * * | Runs at 12 AM, 6 AM, 12 PM, 6 PM |
Where Are Cron Expressions Used?
Linux/Unix Crontab
The original use case. The crontab -e command lets you schedule scripts and commands on any Unix-like system. Each line in the crontab file is a cron expression followed by the command to run.
CI/CD Pipelines
GitHub Actions, GitLab CI, and Jenkins all support cron-based scheduling. Use cron expressions to trigger nightly builds, periodic security scans, or automated deployments on a regular cadence.
Cloud Schedulers
AWS EventBridge (CloudWatch Events), Google Cloud Scheduler, and Azure Logic Apps all accept cron expressions for triggering Lambda functions, Cloud Functions, or other serverless workloads on a schedule.
Application Frameworks
Frameworks like Spring Boot (@Scheduled), Laravel (Task Scheduling), and Node.js (node-cron) let developers schedule background jobs using cron syntax directly in application code.
Tips for Writing Cron Expressions
Start with a Preset
Begin with the closest common schedule (every hour, every day) and then customize individual fields. This prevents mistakes from building expressions entirely from scratch.
Mind the Timezone
Cron expressions don't include timezone information. Your server, CI/CD platform, or cloud provider determines the timezone. Most cloud services default to UTC. Always verify what timezone your scheduler uses before deploying.
Test Before Deploying
Use this generator to verify your expression reads as expected. The human-readable explanation helps catch subtle errors — like scheduling for AM instead of PM, or confusing day-of-month with day-of-week.
Avoid Overlapping Schedules
If your job takes longer than the interval between runs, you can end up with overlapping executions. For long-running tasks, use a locking mechanism or ensure the interval exceeds the maximum job duration.
Frequently Asked Questions
What is a cron expression?
A cron expression is a string of five fields separated by spaces that defines a schedule for automated tasks. The five fields represent minute, hour, day of month, month, and day of week. Cron expressions are used by Unix/Linux cron daemons, CI/CD tools like GitHub Actions, and task schedulers like AWS CloudWatch Events.
What does each field in a cron expression mean?
A standard cron expression has five fields: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-6, where 0 is Sunday). An asterisk (*) means 'every', a slash (/) defines intervals (e.g., */5 means every 5), a comma separates multiple values, and a hyphen defines ranges.
What does */5 mean in a cron expression?
The */5 syntax means 'every 5 units'. For example, */5 in the minute field means 'every 5 minutes' (at minutes 0, 5, 10, 15, etc.). Similarly, */2 in the hour field means 'every 2 hours'.
How do I schedule a cron job to run every day at midnight?
Use the cron expression '0 0 * * *'. This sets minute to 0, hour to 0 (midnight), and leaves day, month, and weekday as wildcards (*), meaning it runs at 00:00 every day regardless of date or weekday.
Is this tool free to use?
Yes, this cron expression generator is 100% free and runs entirely in your browser. No data is sent to any server, and no account or signup is required.
Can I use these cron expressions with GitHub Actions?
Yes. GitHub Actions uses standard cron syntax for scheduling workflows via the 'schedule' trigger. Note that GitHub Actions uses UTC time. You can paste the generated expression directly into your workflow YAML file under 'on: schedule: - cron:'.
What is the difference between cron and crontab?
Cron is the daemon (background service) that executes scheduled tasks on Unix/Linux systems. Crontab (cron table) is the file or command used to define and manage the schedule entries. When people say 'crontab expression', they mean the same cron syntax this tool generates.
Does this tool support Quartz cron expressions?
This tool currently generates standard Unix/Linux 5-field cron expressions. Quartz cron uses 6-7 fields (adding seconds and optionally year). Support for Quartz format is planned for a future update.