Is this cronExpression correct? - quartz-scheduler

I don't know if the below expression is correct:
<property name="cronExpression" value="0 0 12 2 * MON-FRI ?"/>
I try to configure my trigger to fire every second day of every month, no matter the year, at noon, and the day of week has to be between Monday and Friday.
I'd really appreciate if someone could help me. Thanks in advance.

I'm assuming you meant "every second day (every other day), as long as it's MON-FRI".
According to Quartz CronTrigger Tutorial:
'1/3' in the day-of-month field means "fire every 3 days starting on
the first day of the month".
So, 1/2 would mean "fire every second day starting on the first day of the month". A cronExpression like 0 0 12 1/2 * MON-FRI * should then be close to what you want. Checking with
org.quartz.CronExpression.isValidExpression("0 0 12 1/2 * MON-FRI *")
...says that the expression is valid.
However, testing it a little further with:
CronExpression e = new CronExpression("0 0 12 1/2 * MON-FRI *");
e.isSatisfiedBy(new DateTime(2012, 9, 26, 12, 0, 0, 0).toDate());
...throws an exception:
> Exception in thread "main" java.lang.UnsupportedOperationException:
> Support for specifying both a day-of-week AND a day-of-month parameter
> is not implemented.
So, seems like jhouse is right and you just can't do that with a cronExpression.
Maybe something like this would work as a workaround: Quartz cron expression for cron triggers executed every Nth Hour/Day/Week/Month

You cannot specify both a day of month and a day of week - it is not supported.

Related

Rundeck schedule a job on the first monday of the month

I would like to a rundeck job on a specific day of the month. Like for example the first Monday of the month.
I have tried to following: 0 10 10 1-7 * MON *, but this gives me the following error:
"day of week or day of the month must be '?'"
Is there a way to solve this?
Can you try this?
0 0 12 ? 1/1 MON#1 *
You can use http://www.cronmaker.com/ to generate and test your cron expressions.
Use this:
0 0 0 ? * 2#1 *
You can use this website to generate Quartz crontabs.
Try this,
0 0 10 ? 1/1 MON#1 *

Bootstrap datetime picker does not validate hour & minute together when incrementing hours or minutes

I am using the bootstrap datetime picker.
I have set enabledHours between 8 am to 5 pm and stepping to 30. When i pick the current hour to be 5 pm and increment the minute by one step,the result is a invalid date(5:30 pm). The expected result is not to allow incrementing the time, as it produces invalid date.
Same goes for hours also. E.g. if I pick the time as 4:30 pm and try to increment the hour by one step, it produces 5:30 pm which is not valid according to the enabled hours.
Any workaround for this issue?
I found my answer here: https://stackoverflow.com/a/31950948/495000
Turns out the trick is to use the disabledTimeIntervals option instead of EnabledHours.
Note that disabledTimeIntervals takes an array of arrays - representing a list of disabled ranges.
For example, I needed the following, which disables the times between 12:00 AM to 06:59 AM, and between 6:01 PM and 11:59 PM (technically 12:AM the next day the way it's written...). If you consider the inverse, this means I'm enabling from exactly 7:00 AM to exactly 6:00 PM.
.datetimepicker({
format: 'hh:mm A',
stepping: 15,
disabledTimeIntervals: [
[moment().hour(0).minutes(0), moment().hour(6).minutes(59)],
[moment().hour(18).minutes(1), moment().hour(24).minutes(0)]
]

Rexx: increment current time value

Hi I'm running REXX script on ZOC terminal and i want to display current time and ETA like this:
start time 22:44:24
end time 22:56:24
but I don't know how to increment current time ???
maybe to convert time to seconds then increment it and then convert time in seconds back to hh:mm:ss ??
I tried this way but dont know how to convert back time from seconds
intTime= TIME('S')+900
say="start time " TIME()
say="end time " intTime
One way would be along the lines of:-
intTime = TIME('S') + 900
hours = (intTime % 3600) // 24
minutes = (intTime // 3600) % 60
seconds = intTime // 60
endtime = RIGHT(hours,2,'0') || ":" || RIGHT(minutes,2,'0') || ":" || RIGHT(seconds,2,'0')
NOTE!! I don't have access to test this and it's been many years since I've written Rexx or had access. However, I think the basic process would work. That is:-
1) Extract the hours as an integer from the time (catering for the the potential to cross into the next day or days ie the // 24 ()).
2) Extract the minutes, as an integer, from the time, after dropping/subtracting the hours (the remainder of the time divided by hours ie intTime // 3600).
3) Extract the seconds, as an integer, from the time. By obtaining the remaining of diving the time by 60 (will drop hours and minutes).
4) Building the end string as a concatenation of the hours, minutes and seconds. With : as the separator between two values (or surrounding the middle values). The right function to include a leading zero.
You could also try:-
intTime = TIME('S',TIME('S')+900,'S')
That is based upon TIME, which may be Object Rexx. I did also read something mentioning an extended TIME/DATE functionality. However, again that may have been referencing Object Rexx. Although, Mike Colishaw's name was mentioned.
Mike Colishaw, I believe, being the creator of the Rexx programming language.

Quartz Cron Schedule Not Triggering

I used this trigger to run job every 1 hour from 12 AM- 8 AM. But this is not triggering at all. Is this expression correct?
0 0/60 12,8 * * ?
You can this site to build and check expressions based on "Quartz Cron" format.
The correct expression is this:
0 0 0-8 * * ?

Quartz Cron String Understanding Issue

I currently have this quartz cron string 0 0/35 11-13 1/1 * ? *. Now what it generally means is Occurs every 1 day(s) every 35 minute(s) between 11 AM and 1 PM. At least from my understanding that is what it means. Though when I look at possible run times I get these.
06/08/2013 11:00:00 AM
06/08/2013 11:35:00 AM
06/08/2013 12:00:00 PM
06/08/2013 12:35:00 PM
06/08/2013 1:00:00 PM
That does not make sense to me. It seems to reset on the hour. Is there anyway for this not to occur? I would like the job to run at 11AM, then 11:35AM and then 12:10PM not 12PM.
Any and all help would be greatly appreciated.
Yes , this is the problem my colleagues encounters every now and then.
As per the documentation for Quartz scheduler ( and yes off-course, as per my understanding of Quartz till now :-p ), cron trigger will be set to fire at "every 35th minute of the hour" and not "every 35th minute in a day".
For your requirement you should use a simple-trigger .
Date firetime=null; //initialize to Your start time of trigger "11.00am"
Date endtime=null; // initialize to Your end time of trigger "1.00pm"
Trigger tr1 = TriggerBuilder
.newTrigger()
.startAt(firetime)
.endAt(endtime)
.withIdentity("First Trigger", "First Group")
.withSchedule(
SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMinutes(35)
).build();
And use another trigger to schedule this trigger daily.:-)