Quartz Cron String Understanding Issue - quartz-scheduler

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

Related

How to print a message in the console between the times form 9.00 AM to 16.30 PM in Flutter?

I want to print a message in the console every hour between the times from 9.00 AM to 16.30 PM using flutter.
You can setup a cron job using this package. Here is an example of cron expression that will perform an action every hour from 9am to 4pm: 0 9-16 * * *.

Autosys | Schedule Job every 30 minutes

Autosys | JIL
i wish to run a job every 30 mins from 2100 till 0600 next day.
when i place the condition in jil for the job as below and try to upload
start_times: "21:00,21:30,22:00,22:30,23:00,23:30,00:00,00:30,01:00,01:30,02:00,02:30,03:00,03:30,04:00,04:30,05:00,05:30,06:00"
i get an error
start_times exceeds 255 bytes.
I think it will work like Piyush said. I would probably put it like this:
run_window: "21:00-06:00"
start_mins: "0,30"
If I remember correctly, you can also use the ":"
start_mins: ":0,:30"
check if :30 works, if not, try like Piyush suggested
run_window: "21:00-06:00"
start_mins: "0,30"
this was working , tested well

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

Issue with Drools Fusion "during" temporal operator

I've started to work with Drools Fusion and faced strange issue with during temporal operator. For a reason I cannot make it too work though for example after operator is working fine.
Here is declaration of my event - it just contains an intervals of particular type:
declare WorkingDayInterval
#role(event)
#timestamp(event_ts_local)
#duration(duration_in_seconds)
end
Here is my rule:
rule "Idles in Processing period"
when
$processing : WorkingDayInterval( subcategory == "processing")
$longIdle : WorkingDayInterval(this during $processing, subcategory == "idle",duration_in_seconds > 600)
then
System.out.println ("Bad Idle Event:");
System.out.println ($processing.event_ts_local);
System.out.println ($processing.duration_in_seconds);
System.out.println ($longIdle.event_ts_local);
System.out.println ($longIdle.duration_in_seconds);
end
When I run it nothing is fired.
However when I change during to after I get following results:
Bad Idle Event:
Mon Feb 25 05:19:00 MSK 2013
2350
Mon Feb 25 05:20:00 MSK 2013
901
and looking at the values I clearly see that based on start timestamps and durations second event is inside the first event and so duration should have been fired.
Is it a bug in the Drools Fusion or I am doing something wrong?
BTW - I am running in a Cloud mode
I think the problem is that you are assuming that #duration is measured in seconds when in reality Fusion expects it to be expressed in milliseconds. So, in your case, $processing event starts at 05:19:00.00 and ends at 05:19:02.35 and $longIdle starts at 05:20:00.00 and ends at 05:20:00.90. As you can see, $longIdle during $processing is false but $longIdle after $processing is true.
Hope it helps,

Is this cronExpression correct?

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.