Complex Cron Patterns - Advanced Scheduling

Combine multiple cron fields for precise scheduling. Master business hours, multi-schedule patterns, and advanced field combinations to build exactly the schedule you need.

Popular Complex Patterns

Standard 9-5 weekdays

0 9-17 * * 1-5

Every hour during business hours (9 AM - 5 PM, Mon-Fri)

Common uses:

  • Business monitoring
  • Hourly reports
  • Customer support checks
  • Sales tracking

Every 15 min during business hours

*/15 9-17 * * 1-5

Every 15 minutes during business hours

Common uses:

  • Real-time dashboards
  • Queue monitoring
  • SLA tracking
  • Active monitoring

Extended hours 8-20

0 8-20 * * 1-5

Extended business hours (8 AM - 8 PM, weekdays)

Common uses:

  • Extended support
  • Global team coverage
  • Long operations

Night shift

0 22-6 * * *

Night shift hours (10 PM - 6 AM)

Common uses:

  • Overnight processing
  • Night maintenance
  • Batch jobs
  • Low-traffic operations

Twice daily

0 0,12 * * *

Twice daily (midnight and noon)

Common uses:

  • AM/PM reports
  • Data sync
  • Backup snapshots
  • Status updates

Three times daily

0 8,13,18 * * *

Three times daily (8 AM, 1 PM, 6 PM)

Common uses:

  • Shift change reports
  • Regular updates
  • Data validation
  • Status checks

First Monday

0 9 1-7 * 1

First Monday of every month at 9 AM

Common uses:

  • Monthly team meetings
  • Sprint planning
  • Monthly reviews
  • Budget review

Weekend maintenance

0 2-6 * * 0,6

Weekend maintenance window (2-6 AM, Sat/Sun)

Common uses:

  • Infrastructure updates
  • Database maintenance
  • System upgrades
  • Full backups

Peak hours only

*/10 10-14 * * 1-5

Every 10 min during peak hours (10 AM - 2 PM)

Common uses:

  • Peak traffic monitoring
  • Load balancing
  • Performance tracking

Business Hours Reference

Standard 9-5 weekdays
0 9-17 * * 1-5
Every 15 min during business hours
*/15 9-17 * * 1-5
Every 30 min during business hours
*/30 9-17 * * 1-5
Extended hours 8-20
0 8-20 * * 1-5
Night shift
0 22-6 * * *

Multi-Schedule Reference

Twice daily
0 0,12 * * *
Three times daily
0 8,13,18 * * *
Four times daily
0 0,6,12,18 * * *
At specific minutes
0,30 * * * *
Work hours every 2h
0 9,11,13,15,17 * * 1-5
Weekday mornings
0 6,7,8 * * 1-5
Weekend maintenance
0 2-6 * * 0,6

Advanced Pattern Techniques

Combining Hour Ranges with Day-of-Week

Use ranges and lists across multiple fields to create precise schedules:

0 9-17 * * 1-5 - Hour range 9-17 restricts to 9 AM through 5 PM; day-of-week range 1-5 restricts to Monday through Friday
*/15 8-18 * * 1-5 - Step value */15 in the minute field combined with hour range creates high-frequency business-hours monitoring
0 8-18/2 * * 1-5 - Step value /2 within hour range 8-18 runs at 8, 10, 12, 14, 16, 18

First/Last Day-of-Week in a Month

Standard cron has no built-in "first Monday" or "last Friday" syntax, but you can approximate it:

0 9 1-7 * 1 - First Monday: day-of-month 1-7 combined with day-of-week 1 (Monday) ensures it only runs on the Monday that falls in the first 7 days
0 17 25-31 * 5 - Last Friday (approx): day-of-month 25-31 combined with day-of-week 5 (Friday) catches the last Friday in most months
Note: The day-of-month and day-of-week fields in standard cron are OR-ed together in some implementations. Verify behavior with your specific cron daemon.

Avoiding Overlapping Executions

Complex patterns with high frequency can trigger overlapping runs. Protect against this:

  • Use file-based locks (e.g., flock) to prevent concurrent execution of the same job
  • Check for a running PID before starting a new instance
  • Set execution timeouts shorter than the interval between runs
  • Log start/end times to detect jobs that routinely overlap with the next scheduled run

Industry-Specific Examples

SaaS & Web Apps

Business hours monitoring*/15 9-17 * * 1-5
Peak traffic handling*/10 10-14 * * 1-5
Multi-timezone support0 0,8,16 * * *
Maintenance windows0 2-6 * * 0,6

Healthcare

Shift-based processing0 7,15,23 * * *
Medication reminders0 8,13,18 * * *
Report generation0 6,14,22 * * *
Compliance monitoring0 9-17 * * 1-5

Financial Services

Market hours monitoring*/5 9-16 * * 1-5
Pre/post-market processing0 6,7,8,17,18 * * 1-5
Multi-timezone reporting0 0,8,16 * * 1-5
End-of-day reconciliation0 17 * * 1-5

Education

Class schedule processing0 8-15 * * 1-5
Semester boundaries0 9 1-7 1,6,9 1
Academic calendar0 9 1 * *
Grading periods0 17 25-31 * 5