What is the most reliable way to schedule a job with cron scheduler is Quartz that repeats every N days starting from a specific date - scala

In our app, we have an ability to schedule tasks and we converting this functionality to Quartz. One of the problems that I have is scheduling recurring task that should run, for example, every third day.
The cron expression that I had in mind first of all is:
0 37 18 */3 * ? *
But what this will do, is execute that job on 1,4,7, etc... Which is fine, assuming that I want to start from the first day of the month. However, how to deal with this issue if I need to start from 11th?
I could do something like this:
0 37 18 11/3 * ? *
But, in this case, I will always miss all the days before the 11th.
Also, when the time comes for the next month, the expectation that the day of the month will now be different (on one month the job executed on 1st, and on another it could be on 2/3), but based on the cron above it will restart on the same day (e.g. 1st).
I could, of course, count using hours, but then I will have an issue with day light saving?
What is the correct way to organize it? Or am I missing something?
UPDATE
Possible solution is to use simple trigger, as per http://www.quartz-scheduler.org/documentation/quartz-2.1.x/cookbook/BiDailyTrigger.
But in this case, how do I resolve DST problem?
Thanks,

Related

UiPath Orchestrator Triggers - Cron Expression For specific day of month or next working day if not a working day

I've currently got this Cron expression that I'm using to trigger a process in UiPath Orchestrator:
0 0 15 21W * ? *
Runs on the closest working day to the 21st of each month at 3pm.
However I need it to run on the next working day at 3pm if the 21st is a non working day.
Tried searching for an answer and nothing quite fit the brief.
I used this website to build my expression (which is a great tool) but it only had an option for 'nearest day' and not next working day given a specific day of month: https://www.freeformatter.com/cron-expression-generator-quartz.html
As you don't need the nearest day, you can't use the functionality of Orchestrator cronjob. I would recommend creating a wrapper process as follows:
Create a new process, let's call it StartJobByCheckingDate
Now create a trigger that starts StartJobByCheckingDate each day at 3pm
So that process is now your manager of your desired process
Now we need to check if it is the 21th day
Here you have different ways to solve it
You could create a DataTable or even a file in the StartJobByCheckingDate process, that contains all the different days where your desired process should be fired (but this is very manual, you might not want to update this every year, so this might not be the smartest but the easiest solution)
The other idea is to check if the current day is the 21th day. If so check if it is Saturday/Sunday (non-working day).
If true: you could now create a empty dummy file somewhere that tracks that the 21th was a non-working day, and the next day you check that file existing, if it exists you check the current day to be a working day, and if so you delete the file again and start your desired process
If false: just start your desired process directly
I think 2. idea would be that best. Sure you have 365 jobs runs/year. But when you keep that helper process smart this will just be seconds.
Another idea instead of using the dummy file, would be to use Entities. Smarter but need some more time to get familiar with.
We have (had) the exact same issue. Since UiPath doesn't offer a feasible solution out of the box, we will work around the restriction using the following strategy: We trigger the actual job daily, considering a custom-built, static NonWorkingDay-list that will just suppress the execution of the robot every day we don't want it to run.
These steps are needed:
Get a list with of all known bank holidays, saturdays and sundays until 2053 or so...
Build a the static exclusion-list using a script that does something like this (pseudocode. I will update the answer once we have actually implemented the solution):
1. get all valid execution dates
loop through every 28th of the month until end of 2053
if the date is in the bankHolidayList then
loop until the next bankDay is found
add it to the list of valid ExecutionDates
else
add the date to the validExecutionDate-list
2. build exclusion-list
loop through every day until end of 2053
if the date is not in the validExecutionDate-list
add it to the exclusionDate-list
Format the csv accordingly and upload it to the orchestrator tenant as a NonWorkingDay-List
Update your trigger to run daily at your desired time, using the uploaded NonWorkDay-Calendar
While the accepted answer will surely work as well, we prefered to go with this approach because having a separate robot that does nothing but executing a UiPath trigger just doesn't seem right to me. With this approach we have no additional code that we potentially need to maintain.
In my oppinion not having a solution for this concern out of the box is a lack of feature that UiPath will (hopefully) fix until end of 2053 ;-)
Cheers
You can configure your trigger to launch oftener, then manage dates at init of your process, but you must set up a list of "holydays" or check in some way.
Also you can use the calendar option of orchestrator (+info)

Quartz Scheduler job runs continuously after trigger

I am using a product called Mirth to reach out to an SFTP server and download a handful of files on a weekly basis. The product has a cron feature, where it allows you to use a cron expression to do configure this function.
The cron expression I am using:
0 45 13 ? * MON *
NOTE: This is not typical Linux-based cron. It's a cron expression spec used by Java for scheduling things even down to the second (https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm).
Is supposed to reach out at 1:45 PM every Monday and pull down files. But when it reaches out it does so continuously for 20 minutes or so, downloading the same files a few hundred times instead of just once.
Is there vagueness in this expression? It seems like it should only call once. I did just notice that there appears to be a space at the very beginning of the expression, not sure how that would make the thing run for 20 minutes again and again, though.
You could ease your crontab scheduling with crontab generators, like ie. this website:
www.crontab.guru
or
www.crontab-generator.org
(These are first two Google results)
From what you described, it looks like invalid syntax for crontab.
EDITED:
1:45 PM every Monday would be:
45 13 * * 1

Scheduling a job to run every Nth week and specific week days starting on specific date with Quartz (Scala)

In continuation of:
What is the most reliable way to schedule a job with cron scheduler is Quartz that repeats every N days starting from a specific date
&
Absolutely unexplainable results for cron based scheduler in Quartz
There is another question regarding possibilities of scheduling with quartz. And the difference between the two above and this one and the fact that I am trying to execute more than a single job for the target period (e.g. Mon, Fri every 4th week)
Let's assume that a user needs to execute a task every 4th week on Wednesday & Friday starting from a specific date.
Of course, I can setup a cron scheduler that will look something like this:
0 0 12 ? 1/4 WED,FRI *
But we are beck to the same problem as described in the linked posts. What this cron expression really mean, is execute the job on Wednesday & Friday of every 4th week of the month.
Another option is to use, calendar interval schedule builder (the perfectly resolves the problem for as long as there is only one day of the week that needs to be considered); however, it does not allow to specify days of a week, but simply calculates the true 4 weeks worth of time based on the start date.
How, if possible, to schedule a job with Quartz, that will be executed every 4th (or any Nth week) on more than a single day of the week? Is it possible to achieve it without multiple triggers?
Thanks,
So, after long digging around, it seems like the only way to solve it with existing Quartz tools is to manage this type of scheduling with more that one trigger (one for every weekday).
Hopefully that helps somebody.

JasperServer: Schedule report at last day of month?

How to schedule report in JasperServer every last day of the month ?
I am trying to schedule a report, but I didn't find any option to get last day of the month like it would be variable eg in Feb it would be 29 or 28 and other may be 30 or 31. But How to specify this at the time of scheduling the report ?
Help me out..
Thanks in Advance...
That's not possible in the JasperReports Server UI today. The Quartz scheduler supports this, so it's certainly possible to get it working via customization (or possible to run the report via web services as Alex K suggests).
Often the reason for running a report on the last day of the month is to include the results from the past month. So it makes sense to schedule the report to run at a minute past midnight on the first of the month. Maybe you can get what you need like that.

Exclude time blocks on particular day [Quartz Schedular]

I am using Quart Scheduler. I want to trigger to in such a fashion so as it excludes timing from xx:xx:xx to yy:yy:yy on day specified (monday, friday. sunday). I know how to exclude particular day. but don't know how not to trigger on given time block on given day?
Can anybody know anything about it?
Please make use of Calendar and HolidayCalendar available in Quartz to achieve this. The Cron expression in Cron-Trigger can also be written smartly to achieve this as well.
Looking at http://www.quartz-scheduler.org/docs/examples/Example3.html, it seems that one can create different job set to do the same task. For each job one can attach a schedule.
If you dont want to run a particular task on say sunday between 1pm and 10pm, but want it to run on sunday the remainder of the day, then you can create two jobs [set to do the same task]. For one give the schedule with time restrictions 00:00 to 13:00. And for the second give time restriction of 22:00 to 23:59.
I hope I understood your problem correctly ...