0

Is it possible to create an expression for quartz scheduler in java which runs the job every 15 minutes but should skip the job runs from Saturday night 9PM to Sunday morning 6AM? So it will be like the job will run all 7 days a week every 15 minutes but should not run from Saturday 9PM to Sunday 6AM (for some maintenance activity at that time).

asked Jul 26, 2021 at 18:25

1 Answer 1

0

You can use a Quartz Calendar to exclude certain days and/or time periods. To support your use-case, you have two choices:

  1. Implement a custom calendar by implementing the org.quartz.Calendar or extending org.quartz.BaseCalendar. Internally your custom calendar can use two CronCalendar implementations described below.

  2. Use two "chained" CronCalendars. By chaining, I mean using one calendar as the base calendar of the other calendar. The first calendar will exclude Saturdays 9pm to midnight, the second will exclude Sundays 00am to 6am. These are the cron expression used by these two calendars:

    • 21-23 ? * SAT
    • 00-05 ? * SUN

Here are a few examples showing how to use calendars in your code:

http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-04.html

https://www.javarticles.com/2016/06/quartz-calendar-example.html

answered Jul 28, 2021 at 7:17
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.