What is a Cron Expression?
A Cron Expression is a string pattern that tells the system exactly when to run a task. In other words, it specifies a schedule for automatically executing commands, scripts, or processes without manual intervention. It originated from the Cron utility in Unix systems.
Cron vs. Cron Expression
Aspect |
Cron |
Cron Expression |
Definition |
A time-based job scheduler found in Unix/Linux systems. |
A string pattern that instructs the scheduler when should run the job |
Role |
Execute tasks according to the schedule |
Describe the schedules in a specific pattern |
Nature |
Software/Utility |
A text expression |
Usage |
Runs as a service in the operating system |
It tells when to run a job |
Origin |
Part of Unix since the 1970s |
Developed as a part of the command format for Cron jobs |
Cron Expression Structure
A standard Cron Expression has five fields (in Unix) or six/seven fields (in some systems like Quartz Scheduler), separated by spaces.
Each field represents a unit of time.
Field |
Allowed Value |
Special Characters |
Example |
Minute |
0-59 |
, - * / |
30 → 30th minute |
Hour |
0-23 |
, - * / |
15 → 3 PM |
Day of Month |
1-31 |
, - * / ? L W |
1 → 1st day of the month |
Month |
1-12 or Jan-Dec |
, - * / |
1 or Jan → January |
Day of Week |
0-6 or Sun-Sat |
, - * / ? L |
0 or Sun → Sunday
1 or Mon → Monday |
![Cron diagram]()
Example
45 19 * * Fri
Run every Friday at 19:45 or 7:45 PM
Quartz Cron Format
Quartz scheduler adds seconds at the start and an optional year at the end. Some of this usage you can find in Java, Sprint etc.
Seconds Minutes Hours DayOfMonth Month DayOfWeek [Year]
Example
0 0 13 12 8 ? 2025
Run at 1:00 PM on August 12, 2025
Special Characters in Cron Expression
Symbol |
Meaning |
* |
Any value |
, |
Multiple values |
- |
Range of values |
/ |
Step values |
? |
No specific value (Quartz only) |
L |
Last (e.g., last day of month) |
W |
Nearest weekday |
# |
Nth day of month (e.g., 2#1→First Monday) |
Common Cron Expression Examples
Expression |
Runs At |
* * * * * |
Every minute |
* 5 * * * |
Every 5 minutes |
0 6 * * 1-5 |
6:00 AM on weekdays (Monday – Friday) |
0 */15 * * * |
Every 15 minutes |
0 0 0 25 12 * |
Midnight on 25th December |
0 * * * * |
Every hour |
0 0 * * * |
Every day at midnight |
0 9 * * * |
Every day at 9 AM |
0 0 * * 0 |
Every Sunday at midnight |
0 0 1 * * |
First day of every month |
Where is Cron Expression Used?
- Unix/Linux: Automating scripts and system maintenance
- Web hosting: Scheduling backups, email reports
- Cloud Platform: Azure Functions, Aws Lamda, Google Cloud Scheduler
- CI/CD Pipelines: Azure DevOps, GitHub Actions, Jenkins
Conclusion
Cron expressions are an essential tool for automation and task scheduling. They allow users and systems to define exact time and intervals for running jobs.