Quartz Scheduler job runs continuously after trigger - quartz-scheduler

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

Related

Schedule Crontab to be Replaced by Pre-Configured File Daily in Python

My level of understanding with Python is extremely limited, so I'm sorry if I don't use the correct terms / ideas here.
I have a Raspberry Pi, and on the crontab, I have a few scripts scheduled to run at certain times each day. These fire every day when I need them to, and it works fine.
There are some days when I need to alter the time some scripts fire, and it's usually in the evening when I need to make an adjustment, changing the time a script runs at night. This change only applies to the day I'm making the change, and the next day, I'd need the scripts to follow their normal schedule. So for instance:
The standard daily script schedule
00 21 * * * python /path/.../script1.py
15 21 * * * python /path/.../script2.py
30 21 * * * python /path/.../script3.py
Some days I need to change this to a slightly changed schedule, like this:
15 21 * * * python /path/.../script1.py
25 21 * * * python /path/.../script2.py
35 21 * * * python /path/.../script3.py
Or like this:
30 20 * * * python /path/.../script1.py
35 20 * * * python /path/.../script2.py
55 20 * * * python /path/.../script3.py
Sometimes the gap between the scripts stays the same, sometimes they don't. Sometimes the scripts will run later in the day, sometimes the scripts will run earlier.
This is just a convenience issue, but sometimes the day after I make this alteration, I forget to go back into the crontab and change the times back to the standard schedule. Most every day needs to be the standard schedule, and these adjustments are essentially one-off changes that happen from time to time.
Is there a way to create a file that has all the standard times listed (a 'master' file of sorts), and schedule it to be installed as the crontab, replacing the crontab that has any changes that may have been made on the crontab the day before? Essentially I want a way to have all the default times for all my scripts (there are many more than 3) revert back after I make any one-off changes. I would likely run that revert process around noon each day.
Thanks in advance for your help!

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)

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

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,

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.

Windows Task Scheduler - Run only during window of time

I have a task already set up in the Windows Scheduler (on Win Server 2008). It works great but it can put a burden on the system during peak hours (when the box is being used for other things). I currently run the job every 15 minutes. Can Task Sch. be setup to run every 15 minutes but only during a certain window of time. So I could set it up to run every 15 min, but only from 5pm to 5am -- and not run at all from 5am to 5pm?
Set a daily schedule starting at 5pm. In the Advanced dialog, click Repeat task, then specify Every=15 minutes, Until:Time=5am.
Edit: The above instructions are for Windows 2003 Server or XP. If Windows Server 2008 is like Windows 7, then you can do the same thing through the Triggers tab. Set a daily trigger, Start=5pm, Repeat Task Every=15 minutes, For a duration of=12 hours.
You don't need to stick with the pre-defined times - you can type into these fields any value you wish.
For Windows 2008 & above this is what I did:
Create task
Triggers tab
New ...
Use the following settings
In this particular example I want to run the task from 12:06 AM to 23:50 PM.
In "for a duration of" I entered the amount of minutes I want it to run for. Actually you could also enter some thing like 23:50:00 in the "for a duration of" field. It will automatically convert it to minutes after you click OK. That was my experience.
In the triggers tab you can add multiple triggers by using the "New" button. See screenshot below.
You have to set on the the Start field: 5:00:00 AM and on 'for duration of' you have to write '12 hours' or '12:00:00'