Cron Expression Syntax: A Complete Guide
Published on · 231 words
Want to follow along? Open the free Cron Editor
Cron expressions are used to schedule tasks in Unix-like operating systems. They consist of five fields that specify when a command should run.
This guide breaks down every aspect of cron expression syntax so you can write schedules with confidence.
The Five Fields of Cron
A cron expression consists of five time-and-date fields followed by the command to execute.
- Minute (0-59): which minute of the hour
- Hour (0-23): which hour of the day
- Day of Month (1-31): which day of the month
- Month (1-12): which month of the year
- Day of Week (0-7): which day of the week (0 and 7 are Sunday)
Special Characters
Cron supports several special characters to create flexible schedules.
- *: every value (all)
- ,: list of values (1,3,5)
- -: range of values (1-5)
- /: step values (*/5 = every 5)
Common Patterns
Some cron patterns are used so frequently they have become standard.
Frequently Asked Questions
What does * * * * * mean?▼
It means every minute of every hour of every day of every month.
How do I run every 5 minutes?▼
Use */5 * * * * to run a command every 5 minutes.
Can I use day names?▼
Yes, you can use day names (sun, mon, tue...) or numbers (0-7) in the day-of-week field.
Difference between */2 and 0/2?▼
They produce the same result for most fields in practice.
Try it now - free, private, and instant
Use our free Cron Editor tool right in your browser.
Launch the Cron Editor