Search code examples
cronquartz

Different schedule for Weekdays and weekends


In Quartz or Cron is there a way to write a single expression to have different schedules for weekdays and weekends ?

So say 12 noon during weekdays and 8 AM during weekends.


Solution

  • I don't know of a way to to this in cron with a single expression. You can do it with 2 lines, though.

    0 12 * * 1-5 [your script call]
    0 8 * * 6,7 [your script call]

    The last column (day of week) can have a range, or a list. Day of week is 1-7 (Mon - Sun), either 0 or 7 can represent Sunday. HTH