What is Hyphen Range (-)?

A special character defining a contiguous range of values in a cron field.

Definition

The hyphen (-) defines an inclusive range of values within a cron field. For example, "9-17" in the hour field means "every hour from 9 AM to 5 PM," and "1-5" in the day-of-week field means "Monday through Friday." Ranges can be combined with step values: "0-30/10" means "every 10 minutes during the first half hour."

๐Ÿ’ก

Simple Analogy

Like saying "from 9 to 5" โ€” it covers every value between and including the start and end numbers.

Why It Matters

Ranges make business-hours and date-range scheduling simple and readable. "9-17" is instantly understandable as working hours. Without ranges, you would need to list each value individually.

How to Verify

Verify the range includes both endpoints. "9-17" includes hours 9, 10, 11, 12, 13, 14, 15, 16, and 17 โ€” that is 9 values. Count: end - start + 1.

โš ๏ธ

Common Mistakes

Writing ranges backwards (17-9 is invalid โ€” start must be less than end). Assuming ranges wrap around midnight (23-2 does not work; use 23,0,1,2 instead). Forgetting that ranges are inclusive of both endpoints.

โœ…

Best Practices

Use ranges for business hours (9-17), weekdays (1-5), and seasonal months (6-8 for summer). Combine with step values for patterns like "every 2 hours during business hours" (9-17/2). For overnight ranges, use two ranges with a comma: "22-23,0-6".

Cron Expression Generator

Build your cron expression

Try it free โ†’

Frequently Asked Questions

What is Hyphen Range (-)?

The hyphen (-) defines an inclusive range of values within a cron field. For example, "9-17" in the hour field means "every hour from 9 AM to 5 PM," and "1-5" in the day-of-week field means "Monday through Friday." Ranges can be combined with step values: "0-30/10" means "every 10 minutes during the first half hour."

Why does Hyphen Range (-) matter for cron jobs?

Ranges make business-hours and date-range scheduling simple and readable. "9-17" is instantly understandable as working hours. Without ranges, you would need to list each value individually.

What are best practices for Hyphen Range (-)?

Use ranges for business hours (9-17), weekdays (1-5), and seasonal months (6-8 for summer). Combine with step values for patterns like "every 2 hours during business hours" (9-17/2). For overnight ranges, use two ranges with a comma: "22-23,0-6".

Related Terms