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

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)

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.

Related

Systemd timer for the first business day of every month

Just wondering if there is a way to schedule a timer for the first business day of every month?
Basically the first day of every month which is not a weekend.
I am trying to avoid creating a wrapper script if possible
[Timer]
OnCalendar=Mon..Fri *-*-1..3 00:00:00
This executes the service
only if it is a business day
only the first 3 days of the month
The intersection of these directives leads to the first business day (Monday to Friday) of every month.
Examples:
Day 1 is Saturday, day 2 is Sunday, day 3 is Monday. Script runs the 3rd
Day 1 is Sunday, day 2 is Monday. Script runs the 2nd
Day 1 is Thursday. Script runs the 1st
Source: ArchWiki

Quartz simple trigger vs cron trigger

For my enterprise application, i need do the batch operation with time of intervals.
While referring quartz scheduler, there are two types. One is simple trigger and another one is cron trigger.
I am confusing about these concepts. Please explain me with simple example.
Please refer to the examples given in the documentation.
CronTrigger
CronTrigger is often more useful than SimpleTrigger, if you need a job-firing schedule that recurs based on calendar-like notions, rather than on the exactly specified intervals of SimpleTrigger.
Some Examples
“every Friday at noon” or “every weekday and 9:30 am”, or even “every 5 minutes between 9:00 am and 10:00 am on every Monday, Wednesday and Friday during January”, .
CronTrigger Example 1 - an expression to create a trigger that simply fires every 5 minutes
“0 0/5 * * * ?”
CronTrigger Example 2 - an expression to create a trigger that fires every 5 minutes, at 10 seconds after the minute (i.e. 10:00:10 am, 10:05:10 am, etc.).
“10 0/5 * * * ?”
CronTrigger Example 3 - an expression to create a trigger that fires at 10:30, 11:30, 12:30, and 13:30, on every Wednesday and Friday.
“0 30 10-13 ? * WED,FRI”
CronTrigger Example 4 - an expression to create a trigger that fires every half hour between the hours of 8 am and 10 am on the 5th and 20th of every month. Note that the trigger will NOT fire at 10:00 am, just at 8:00, 8:30, 9:00 and 9:30
“0 0/30 8-9 5,20 * ?”

Cron Expression for dynamic schedule

I am looking for a Cron Expression that will schedule in different time in different weekdays. I'm not sure if that is possible or not.
I searched and found that Cron can schedule "At 8:00am every Monday through Friday" or "At 1:30am every last Friday of the month".
But is it possible to get cron expression that will schedule like, say :
10:00 AM every Monday
12:00 AM every Tuesday
02:00 PM every Wednesday
04:00 PM every Thursday
06:00 AM every Friday
I'm new to Cron Expression, and through google, I could not find whether it is possible.
My query is :
Is it possible to create cron expression like that?
If possible, then can you provide sample expression for that? along with some tutorial to know how to create them.
No, you need to write a different cron expression for each time-day(s) combination.
Ubuntu has a nice tutorial about cron. To run something at 10:00 AM every Monday:
# Min Hr Day Month Weekday Command
00 10 * * 1 touch /tmp/cron_has_run
Note that weekdays are counted from zero, so 0 is Sunday, 1 is Monday, etc.

Confused with dates and days in cron jobs

I am having trouble understanding how dates and days work together in a cron job.
Say I have the following command:
0 23 5 1 3 COMMAND
This translates to 23:00, on 5th of January, on Wednesday.
The problem is, that January 5th is a Sunday. How exactly will this command work out? Is the command going to be executed for both January 5th AND for every Wednesday on the month January? Or will it execute just the '5 1' bit?
I am really sorry if it is a really basic question and possibly stupid but to me it really does not make any sense.
Thank you in advance!
Commands are executed by cron when the minute, hour, and month of year fields match the current time, and at least one of the two day fields (day of month, or day of week) match
Ref: Man Page

how to set event duration in ekevent in icalender?

I created event in iCalendar. Its start date is today and end date is next month 15th. and this is recurrence type of event . so if set event as recurrence event then changed end date as same as recurrence end date. I want to give time duration of event,like 3.30P.M to 6.30P.M. How to i set event duration ....
"DTSTART;TZID=US-Eastern:19970105T083000
RRULE:FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9; BYMINUTE=30
First, the "INTERVAL=2" would be applied to "FREQ=YEARLY" to arrive at "every other year".
Then, "BYMONTH=1" would be applied to arrive at "every January, every other year".
Then, "BYDAY=SU" would be applied to arrive at "every Sunday in January, every other year".
Then, "BYHOUR=8,9" would be applied to arrive at "every Sunday in January at 8 AM and 9 AM, every other year".
Then, "BYMINUTE=30" would be applied to arrive at "every Sunday in January at 8:30 AM and 9:30 AM, every other year".
Then, lacking information from RRULE, the second is derived from DTSTART, to end up in "every Sunday in January at 8:30:00 AM and 9:30:00 AM, every other year".
Similarly, if the BYMINUTE, BYHOUR, BYDAY, BYMONTHDAY or BYMONTH rule part were missing, the appropriate minute, hour, day or month would have been retrieved from the "DTSTART" property."
Please any one guide me how to set ...
I know how to recurrence rule is working but my question is how to set event duration.
No client that I know of support BYMINUTE and BYHOUR so unless this event is for your own application consumption, you are asking for trouble. IN any case, the very first instance will use the DTSTART value as the beginning, regardless of what you may have put in BYMINUTE and BYHOUR (see https://www.rfc-editor.org/rfc/rfc5545#section-3.8.5.3)
Then you can use DTEND or DURATION:
DTSTART;TZID=US-Eastern:19970105T083000
DTEND;TZID=US-Eastern:19970105T153000
or
DTSTART;TZID=US-Eastern:19970105T083000
DURATION:PT7H