How to implement recurrence functionality by using quartz scheduler? - quartz-scheduler

I have scenario to implement recurrence functionality by using Quartz Scheduler. The end user will give an input like Week Days (Monday to Friday) or Month(January to December) or Day (1 to 31),Start Date and Recurrence.
Example :
Week Days : Tuesday or Month : January or Day : 19
Start Date : 01/19/2015
Recurrence :4
In the above example, if user is selected weekdays as Tuesday, start date and recurrence. Hence Quartz Job should run 4 times i.e Tuesday,Wednesday,Thursday and Friday.
How can I achieve recurrence functionality by using quart scheduler?

Related

I'm trying to calculate 3 days from today, but not include weekend or holidays, but

The workday function should work for this. I have a Range called "Holidays". The problem is that workdays doesn't count the weekend days. I need to count the weekend days. BUT, if the 3rd day comes on a weekend or a holiday choose the next non-weekend or non-holiday day. A2 is the Effective Date of the contract, which is the start date. I'm trying to calculate the day on which the Earnest Money is due. See the attached chart as to how it should calculate.
=if(OR(A5="",A5>workday(A2,3,Holidays)),workday(A2,3,Holidays),"") is the formula I have but it works for Effective dates that fall on a Sunday, Monday, Tuesday and Wednesday, but not for Effective dates that fall on a Thursday, Friday, Saturday.
Starting from Today
Use this formula to get the dates starting from today
={ArrayFormula(
VLOOKUP(WEEKDAY(SEQUENCE(7,1,TODAY(),1),2),
{SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},2)),
BYROW(SEQUENCE(7,1,TODAY(),1),
LAMBDA(d, VLOOKUP(WEEKDAY(IF(IFNA(MATCH(d+3,F2:F13*1,0),"")="",d+3,d+4),2),
{SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},2)))}
Starting from Monday
={ArrayFormula(
VLOOKUP(WEEKDAY(SEQUENCE(7,1,TODAY()-WEEKDAY(TODAY(),3),1),2),
{SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},2)),
BYROW(SEQUENCE(7,1,TODAY()-WEEKDAY(TODAY(),3),1),
LAMBDA(d, VLOOKUP(WEEKDAY(IF(IFNA(MATCH(d+3,F2:F13*1,0),"")="",d+3,d+4),2),
{SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},2)))}
Starting from Monday using Lambda
Starting from the current week monday.
=ArrayFormula(LAMBDA(vl,wd,
{VLOOKUP(WEEKDAY(wd,2),vl,2),
BYROW(wd,LAMBDA(d, VLOOKUP(WEEKDAY(IF(IFNA(MATCH(d+3,F2:F13*1,0),"")="",d+3,d+4),2),vl,2)))})
({SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},
SEQUENCE(7,1,TODAY()-WEEKDAY(TODAY(),3),1)))
Explanation
You need the Calendar Year 20xx Legal Public Holidays to skip one day if matched the legal holidays date after adding 3 days.
Used formulas help
BYROW - SEQUENCE - TODAY - LAMBDA - VLOOKUP - IF - IFNA - MATCH - ARRAYFORMULA

Trigger Azure Data Factory Pipeline on second Friday from end of month and on Tues, Wed and Thurs of the same week

I need a Pipeline to trigger on the Monthend week (Tues, Wed, Thurs and Friday) of a month.
Monthend is defined as,
"Last but one" Friday Or
Second Friday from the end of the month.
For Example, For month of June 2021, 18th is the Monthend (Orange color as shown in the image)
Calendar Image
If its just on Monthend i.e. Second Friday from the end of calendar month, its easy. Just use Occurrance as -2 and day as Friday in the Scheduled trigger and add to a pipeline to trigger,
"schedule": {
"monthlyOccurrences": [
{
"day": "Friday",
"occurrence": -2
}
]
}
but I also need to run on the Tues, Wed and Thurs of the same week, which I find it difficult as these weekdays can be second or third from the end of the calendar month. For example: For June 2021, as shown in the image, I also need to run on 15th (Third Tuesday from the end of calendar month), 16th (Third Wednesday from the end of calendar month), 17th (Second Thursday from the end of calendar month).
Can you let me know if this can be implemented using triggers of Azure data factory? If not, any otherways of implementing? Thank You!
The scheduled trigger alone is not capable of that logic (as of 2021-05-04). Easiest solution would be to use some other scheduling application.
For a purely Data-Factory solution, schedule the trigger for all the days the desired days could possibly occur on. Then modify the pipeline to do logic to determine whether the current day is actually one of the desired days.
Implementation details and sample code
The logic:
Find the last day of the month (First of the next month less 1 day).
Subtract a week so you are in the second-to-last week
Loop over [0,-1,-2,-3,-4,-5,-6] as number of days to add to the date. This produces the dates of each day of the week.
Use the dayOfWeek function to change the date into which day of the week it is
Filter to get the Friday date
Ask whether today is between the Friday date and Friday date - 3 days

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 - 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)
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.

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.