fire job every 90 min continuously - cron

How should I go about creating a cron expression that will fire every 90 minutes continuously after midnight?
Documentation here:
http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
Pratik

I would just configure two cron jobs:
#min hr everything else
0 0,3,6,9,12,15,18,21 ...
30 1,4,7,10,13,16,19,22 ...
(you could also use the short form for the hours as well, like 0-21/3 and 1-22/3).

Don't use CronTrigger for such a schedule. Use one of the other trigger types such as SimpleTrigger or CalendarIntervalTrigger etc.

Related

hybris make cronjob execute over n hours, then n+1 hours

How do I achieve this? I mean, I can make it execute every n hours using triggers. But how do I make it execute every n hours, then every n + 1 hours, then repeat this loop?
You can change trigger of cron job with updating job trigger item (Trigger).
You can create a single trigger for this. For example "5 3-6/1 * * *" which stands for "At minute 5 past every hour from 3 AM through 6 AM."
After your business logic is done receive the trigger of the cron job set a new activation time and store it via model service.
This will re-schedule the cronjob out-of-the-box.
In you case it could be helping to configure the trigger at a fixed date in the past so the automatic re-scheduling do not happen.

Need Cron expression to trigger job for every 90 minutes in AWS Glue

In AWS glue service there is an option to trigger job by custom CRON expression. Before i used this (0/2 * * ? *) cron expression to trigger job for every 2 hours.
Now I need to change the cron expression to trigger every 90 minutes, i.e for every 1 and a half hour. I tried with many cron expressions but that did not triggered for every 90 minutes. Even if i give for 90 minutes, it trigged for every 1 hour.
Can anyone help me out by providing the correct cron expression to trigger job for every 90 minutes ?
You can use the following pattern which was based on Bill Weiss' answer on Server Fault. It was modified to comply with the unique syntax AWS uses (reference here):
0 0-21/3 * * ? *
30 1-22/3 * * ? *
You'll have to define two separate Glue Triggers to accomplish this, each with the same job settings.
If curious, the syntax reads:
Run every 0th minute for every third hour for 0-21 hours
Run every 30th minute for every third hour for 1-22 hours

Quartz cron expression to run job with interval of minutes

I wonder if it is possible to write an cron expression with several conditions:
Job should be run with given interval in minutes. For example with interval 42 minutes the fire times would be 10:00, 10:42, 11:24, 12:06 and etc.
If the current minute does not end with 0 (e.g. 10:28,10:29), then cron first fire time should be 10:30. So it means that first fire time should have "round" minutes.
I hope that you understand these conditions. Is it possible to describe them with quartz cron?
You can use job trigger like described below in Quartz.net 3.0:
var jobTrigger = TriggerBuilder.Create()
.StartNow()
.WithSimpleSchedule(s => s
.WithIntervalInMinutes(42)
.RepeatForever())
.Build();
And you can restart app at first round time, so it will fire first time at the same time only.
I usually use http://www.cronmaker.com/ to generate my cron expressions. And if you try the every 42 mins option you'll get the following expression: " 0 0/42 * 1/1 * ? *". As for the "round" minutes thing, you can try this when building your trigger:
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity(JobTrigger, JobGroup)
.WithCronSchedule(CroneExpression)
.StartAt(new DateTimeOffset(DateTime.Now,
TimeSpan.FromMinutes(DateTime.Now.Minute % 10)))
.Build();
It is not possible, see for explanation and similar issue: Quartz.net - Repeat on day n, of every m months?
it is also not possible by Cron expressions. To do this, you would need to apply some complex logic, use some operator that is not present in evaluators. Why do you need this? Would you like to combine those 2 requirements and create single complex pattern?

How to run every 25 minutes every day from 9 AM to 5 PM in Quartz scheduler?

I am using the Quartz Scheduling and I've tried to create a trigger that starts every day at 9 AM until 5 PM, every 25 minutes. It should like that:
9:00, 9:25, 9:50, 10:15, 10:40, 11:05, etc
The final quarts expression looks like that:
0 0/25 9-17 * * ? *
But the execution looks like that:
9:00, 9:25, 9:50, 10:00, 10:25, 10:50, 11:00, etc
There is any way to reach this schedule:
9:00, 9:25, 9:50, 10:15, 10:40, 11:05, etc
or I should change quartz?
Thank you!
Actually this question is similar to Cron expression to be executed every 45 minutes SO question.
Cron expression will not allow you to do that as it defines the exact date and times, when a trigger must be fired. And setup like your actually means "fire every 25 minutes, starting at minute 0 of every hour".
You can achive what you want by using SimpleTrigger with .WithIntervalInMinutes(25) configuration.
SimpleTrigger should meet your scheduling needs if you need to have a job execute exactly once at a specific moment in time, or at a specific moment in time followed by repeats at a specific interval.
P.S. Your cron expression will work for 20 minutes (0 0/20 9-17 * * ? *), as 60 is a multiple of 20. Just in case changing interval is not critical to you)
P.S.2 To be honest you can use Cron expressions if setup few trigger for different intervals, but that is useless. Anyway look onto this SO answer

cron job between 8am and 8pm 4 times at specified intervals of time

i need to run a job 'x' times a day. job timing is every (say 'y' hours) between 8am and 8pm.
i read the documentation of cron between could not figure out how to place the "between times". any suggestion or a good tutorial should be really helpful.i could figure out this much.
Found this in a tutorial. I believe this will serve the requierment
SimpleTrigger simpleTrigger = new SimpleTrigger("simpleTrigger", "triggerGroup-s1");
simpleTrigger.setStartTime(d);
simpleTrigger.setRepeatInterval(1000*60*60*24);
simpleTrigger.setRepeatCount(15);
simpleTrigger.setEndTime(new Date(ctime + 60000L));
simpleTrigger.setPriority(10);
scheduler.scheduleJob(jobDetail, simpleTrigger);
scheduler.start();
how could i modify the expression to serve my purpose.
You have a * in your example where you need to put the start/end hours:
0 8-20/y * * *
Where you replace y with the number of hours you want between runs should be fine. If you have some strange time like "1 hour and 15 minutes between runs", it's going to be a pain - probably just easier to calculate each time and enter it explicitly.
I don't know you can express this in cron expression.
However, you can use multiple Quartz triggers to serve this purpose.

Resources