Search code examples
quartz-scheduler

Quartz - schedule jobs every two Weeks regardless of the start time


What is the cron expression for the following schedule :

Monday and Tuesday at 8:00 am, every 2 weeks.

Can we define "Every 3 weeks" regardless of the the start time ? (I don't care if it's every 3 weeks starting from the first week of the month or year, I want to run it for 5 years and literally every 3 weeks)


Solution

  • You can't find a cron expression that meets your schedule. For example this howto states, that:

    You need a SimpleTrigger or CalendarIntervalTrigger to schedule biweekly fire points.

    I think you need two Simple Triggers to define a schedule like "Monday and Tuesday at 8:00 am every 2 weeks", namely one biweekly trigger for each monday, and just like that one biweekly trigger for each tuesday.

    Similarly you could tackle the "Every 3 weeks" problem.