The power of cron expressions lies not in their five fields, but in four special characters that transform simple numbers into flexible scheduling patterns. Understanding the asterisk (*), comma (,), hyphen (-), and slash (/) unlocks the ability to create anything from basic daily tasks to complex enterprise automation schedules.
The Four Characters That Rule Scheduling
While cron expressions use five fields for time specification, only four special characters give them their scheduling power. Each character serves a distinct purpose and can be combined to create sophisticated patterns. Let's explore each one in depth.
The Asterisk (*): The Universal Wildcard
The asterisk is the most fundamental special character in cron. It represents "every possible value" or "any value" for a given field. Think of it as saying "I don't care about this field—use every valid option."
How the Asterisk Works
When you place an asterisk in a field, cron evaluates that field as matching every valid value:
- Minute field (
*): Every minute (0-59) - Hour field (
*): Every hour (0-23) - Day of month (
*): Every day (1-31) - Month (
*): Every month (1-12) - Day of week (
*): Every day of the week (0-7)
Practical Asterisk Examples
Every Minute of Every Day:
* * * * *
This runs 1,440 times per day (24 hours × 60 minutes). It's the most frequent possible schedule and rarely needed in practice—most tasks don't need to run every single minute.
Every Minute During 9 AM Hour:
* 9 * * *
By specifying hour 9 and using asterisks elsewhere, this runs 60 times between 9:00 AM and 9:59 AM every day.
Every Hour on Weekdays:
0 * * * 1-5
The asterisk in the hour field combined with a range in the day-of-week field creates a pattern that runs at the top of every hour, but only Monday through Friday.
Daily at Midnight:
0 0 * * *
Here, asterisks in the last three fields mean "every day of every month and every day of the week," resulting in a simple daily schedule.
Strategic Use of Asterisks
The asterisk is your friend for creating broad schedules. When you want maximum frequency in a particular dimension, use an asterisk. When you need to ignore a dimension entirely (like "any day of the month" or "any month"), the asterisk does that perfectly.
Common mistake: Using * 0 * * * thinking it means "daily at midnight." This actually means "every minute during the midnight hour (12:00 AM to 12:59 AM)." The correct expression is 0 0 * * *.
The Comma (,): The List Builder
The comma separates multiple specific values within a single field. It's how you say "run at these specific times" rather than "run at every time" or "run in a range."
How Commas Work
Commas create an OR condition within a field. The task runs when the time matches any of the comma-separated values.
Practical Comma Examples
Three Times Daily:
0 9,12,18 * * *
This runs at exactly three times: 9:00 AM, noon (12:00 PM), and 6:00 PM (18:00). Perfect for tasks like checking for updates, sending reminder notifications, or generating periodic reports.
Twice Monthly:
0 0 1,15 * *
Runs at midnight on the 1st and 15th of every month. Common for bi-monthly billing cycles, payroll processing, or regular maintenance windows.
Specific Weekdays:
0 8 * * 1,3,5
Runs at 8:00 AM on Monday, Wednesday, and Friday. Useful for tasks that should happen on alternating weekdays rather than every weekday.
Multiple Times Per Hour:
0,15,30,45 * * * *
Runs at four specific minutes every hour: on the hour, at quarter past, at half past, and at quarter to. This executes exactly four times per hour, every hour.
Complex Daily Schedule:
0 6,8,10,12,14,16,18,20 * * *
Runs every two hours from 6:00 AM through 8:00 PM. Good for regular status checks during business hours and evening.
When to Use Commas vs. Slashes
Commas specify exact values, while slashes (covered next) create intervals. Use commas when you need precise control over specific times. Use slashes when you want regular intervals.
For example, 0,30 in the minute field means "at minute 0 and minute 30" (twice per hour). In contrast, */30 means "every 30 minutes starting from 0" (also twice per hour, but conceptually different). They produce the same result in this case, but */30 is more semantic for "every 30 minutes."
The Hyphen (-): The Range Definer
The hyphen creates a continuous range of values. It's shorthand for listing every value between two endpoints.
How Hyphens Work
When you write X-Y, cron interprets this as "every value from X through Y, inclusive."
Practical Hyphen Examples
Business Hours:
0 9-17 * * *
Runs every hour from 9:00 AM through 5:00 PM (hours 9, 10, 11, 12, 13, 14, 15, 16, 17). That's nine times per day, covering a standard 9-to-5 workday.
Weekdays Only:
0 9 * * 1-5
The range 1-5 represents Monday through Friday. Combined with hour 9, this runs at 9:00 AM every weekday—never on weekends.
Night Hours:
0 0-6 * * *
Runs every hour from midnight through 6:00 AM. Useful for maintenance tasks during low-traffic periods.
Morning Hours:
*/5 6-11 * * *
Every 5 minutes from 6:00 AM through 11:59 AM. Combining a range with a step value creates frequent execution during a specific window.
Summer Months:
0 0 1 6-8 *
At midnight on the 1st day of June, July, and August. Ranges work in any field, including months.
End of Business Week:
0 17 * * 4-5
At 5:00 PM on Thursday and Friday—perhaps for generating end-of-week reports.
Combining Ranges with Commas
You can mix ranges and commas in the same field:
0 9-11,14-16 * * 1-5
This runs every hour from 9-11 AM and 2-4 PM on weekdays. The comma separates two different ranges, allowing for gaps in your schedule (like a lunch break).
Another example:
0 6 * * 1-3,5
Runs at 6:00 AM on Monday, Tuesday, Wednesday, and Friday—but not Thursday. This combination of a range and an individual value provides fine-grained control.
The Slash (/): The Interval Generator
The slash specifies step values or intervals. It answers the question: "How often should this repeat within the range?"
How Slashes Work
The syntax */X means "every X units" starting from the minimum value. The syntax Y-Z/X means "every X units within the range Y to Z."
Practical Slash Examples
Every 5 Minutes:
*/5 * * * *
This is the classic example. The task runs at minutes 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 of every hour—twelve times per hour, 288 times per day.
Every 10 Minutes:
*/10 * * * *
Runs six times per hour at minutes 0, 10, 20, 30, 40, 50. Common for monitoring tasks that need frequent updates without being excessive.
Every 2 Hours:
0 */2 * * *
Runs at hours 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22—twelve times per day.
Every 3 Hours During Business Hours:
0 9-17/3 * * *
Runs at hours 9, 12, 15 within the 9-17 range. This is more efficient than listing 9,12,15 when you want regular intervals.
Every 15 Minutes During Peak Hours:
*/15 8-20 * * *
Runs every 15 minutes, but only during hours 8 AM through 8 PM. Outside those hours, nothing happens.
Every Other Day:
0 0 */2 * *
Runs at midnight every 2 days (days 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30). Note this doesn't alternate perfectly—it resets each month.
Every 6 Hours Starting at Midnight:
0 0,6,12,18 * * *
While you could write this as 0 */6 * * *, both are equivalent and run at 12 AM, 6 AM, 12 PM, and 6 PM.
Understanding Step Values
The slash creates evenly spaced intervals. */5 in the minute field means the task runs when the minute value is divisible by 5 (with remainder 0). This is why it runs at 0, 5, 10, 15, etc.—not at 3, 8, 13, 18.
If you need execution at offset times (like 3, 13, 23, 33, 43, 53), you'd use a comma list instead: 3,13,23,33,43,53. Slashes always start from 0 or the range's beginning.
Step Values in Ranges
When combined with ranges, step values create intervals within that range:
0 10-18/2 * * *
This means "every 2 hours between 10 AM and 6 PM," running at hours 10, 12, 14, 16, 18.
Important: The step starts at the range beginning. 10-18/2 means "start at 10, then every 2 hours," not "every 2 hours that fall between 10 and 18."
Combining Special Characters
The real power emerges when you combine these characters strategically:
Complex Example 1: Business Hours Support Checks
*/15 9-17 * * 1-5
*/15: Every 15 minutes9-17: During 9 AM to 5 PM1-5: Monday through Friday
Translation: "Every 15 minutes during business hours on weekdays"—a perfect pattern for checking a support queue or monitoring system health during work hours.
Complex Example 2: Bi-Weekly Reports
0 8 1,15 * 1-5
0: At minute 08: At 8 AM1,15: On the 1st and 15th1-5: If it's a weekday
Translation: "At 8:00 AM on the 1st and 15th, but only if they fall on weekdays"—though note that cron uses OR logic here, so this actually runs on the 1st and 15th regardless of day, AND every weekday. For true "1st and 15th if weekday" logic, you'd need script-level checking.
Complex Example 3: Multi-Time Daily Backup
0 2,10,18 * * *
0: At minute 02,10,18: At 2 AM, 10 AM, and 6 PM
Translation: "Three times daily for database backups"—early morning, mid-day, and evening coverage.
Complex Example 4: Frequent Monitoring Windows
*/5 8-12,13-17 * * 1-5
*/5: Every 5 minutes8-12,13-17: 8 AM to noon, and 1 PM to 5 PM (skipping lunch)1-5: Weekdays only
Translation: "Every 5 minutes during business hours, excluding the lunch hour"—useful for high-frequency monitoring that respects break times.
Common Pitfalls and Mistakes
Overusing Step Values: */1 is the same as *. Don't write */1 * * * *—just use * * * * *.
Range Boundaries: 9-17 includes both 9 and 17. It's inclusive on both ends.
Day of Week vs. Day of Month: When both are specified (neither is *), most cron implementations use OR logic. 0 9 1 * 1 runs on the 1st of the month OR on Mondays, not "1st Mondays."
Invalid Ranges: You can't write 30-10 to mean "30 through 59, and 0 through 10." Ranges must be increasing. For wrapping ranges, use commas: 30-59,0-10 or */20 starting from an offset.
Comma Spacing: Don't put spaces around commas. Write 1,3,5, not 1, 3, 5.
Mastering the Characters
These four special characters—asterisk, comma, hyphen, and slash—are the entire vocabulary of cron expression complexity. Master them, and you can create any schedule imaginable:
- Use asterisks for broad, frequent schedules
- Use commas for specific, discrete values
- Use hyphens for continuous ranges
- Use slashes for regular intervals
Combine them strategically to balance precision with simplicity. A well-crafted cron expression is both powerful and readable.
Want to experiment with these characters without memorizing every rule? Our Cron Expression Builder lets you create complex schedules visually, showing you exactly how each special character affects your execution pattern. It's the fastest way to learn by doing while ensuring your expressions are correct before deployment.