Cron Expression for Hour:Minute to Hour:Minute - cron

I am using Cron Expressions with Quartz.NET, and having a problem generating the cron expression for a Start Hour:Minute and End Hour:Minute
If I have a Job I want to run every 5 minutes from 10:20 AM to 11:25 AM what should be the correct cron expression,
At the moment I have this: 0 20-25/5 10-11 1/1 * ? *
But this only runs at 10:20, 10:25, 11:20 and 11:25
1 Monday, June 6, 2016 11:20 AM
2 Monday, June 6, 2016 11:25 AM
3 Tuesday, June 7, 2016 10:20 AM
4 Tuesday, June 7, 2016 10:25 AM
5 Tuesday, June 7, 2016 11:20 AM
6 Tuesday, June 7, 2016 11:25 AM
7 Wednesday, June 8, 2016 10:20 AM
8 Wednesday, June 8, 2016 10:25 AM
9 Wednesday, June 8, 2016 11:20 AM
10 Wednesday, June 8, 2016 11:25 AM
But what it should do is run from 10:20 AM till 11:25 AM, every five minutes
10:20, 10:25, 10:30, 10:35, 10:40 ....... 11:20, 11:25

Quartz does exactly what you Cron expression is saying, ie every 5 minutes between minutes 20 and 25 included for hours 10 and 11. And there is no way to achieve this with one Cron expression only...
This is usually done using a trigger with daily time interval schedule (TriggerBuilder.Create().WithDailyTimeIntervalSchedule(...)) with 10:20 as daily start time, 11:25 as daily end time and with a 5 minutes interval.
If your trigger HAD TO be fired only on minutes 0 or 5, also add to the trigger a misfire instruction policy to avoid time shifting in case of recovery (See https://dzone.com/articles/quartz-scheduler-misfire)

Related

How to instruct cron to execute a job in airflow Run every 3rd Jan, 3rd April, 3rd July, 3rd Oct at 11:00 AM UTC Time Zone

How to instruct cron to execute a job in airflow Run every 22nd Jan, 22nd April, 22nd July, 22nd Oct at 11:00 AM UTC Time Zone.
I have written below cron command to execute in airflow but it is not running at per scheudled
schedule_interval="0 11 22 1/3 *"
A cron-to-human-translator such as crontab.guru is a convenient tool for writing cron expressions:
0 11 22 1,4,7,10 *
0 = Minute 0
11 = Hour 11
22 = Day 22
1,4,7,10 = Months January, April, July, and October
* = Any day of the week
By default, UTC is applied in Airflow, but you can configure this globally (AIRFLOW__CORE__DEFAULT_TIMEZONE), or per DAG. See documentation: https://airflow.apache.org/docs/apache-airflow/stable/timezone.html#default-time-zone.

how schedule a job in airflow for first 4 business day (not on weekends) of the month

job should run on first 4 business day(not on weekends) at 3 am
ex : 00 03 1-6 * 1-5 ==> jobs are running every day-of-week from Monday through Friday
1 - fri 03:00
4 - mon 03:00
5 - tue 03:00
6- wed 03:00
This is currently not possible with a single cron expression. You could configure "the first Monday-Friday of the month" using the # symbol:
0 3 * * MON#1,TUE#1,WED#1,THU#1,FRI#1
However, sometimes Friday is part of the 4 business days (e.g. Wednesday 1 Thursday 2 Friday 3 Saturday 4 Sunday 5 Monday 6 Tuesday 7), so you cannot simply exclude that.
Within Airflow, you currently have 2 options to work around this:
Implement a timetable
Run your DAG with the expression shown above, and start your DAG with a task to skip all remaining tasks in case the DAG run's date is a fifth working day.

Gmail - Schedule send

I wish gmail gave more Schedule send times by default - not just default
Tomorrow morning Mar 24, 8:00 AM
Tomorrow afternoon Mar 24, 1:00 PM
Monday morning Mar 30, 8:00 AM
I'd love to have options like
in 2 minutes
in 10 minutes
in 1 hour
in 2 hours
in case I realize I need to add something ...
I guess we need to write a browser extension for that
but you never know that's why I'm asking here ...
any advice?
thank you ...

CronExpression every 2 days

I know this question was asked before. But the answers in those questions are not correct in my opinion.
I want to have a CronExpression for (Quartz) that schedules every 2 days.
The CronExpression "should be" 0 0 0 1/2 * ? *.
BUT: Starting today (9th October 2017) CronMaker shows that this is not true. This expression basically means: schedule every 2 days starting on the first of each month. That means: starting on 9th October 2017 the next times are:
Wednesday, October 11, 2017 12:00 AM
Friday, October 13, 2017 12:00 AM
Sunday, October 15, 2017 12:00 AM
Tuesday, October 17, 2017 12:00 AM
Thursday, October 19, 2017 12:00 AM
Saturday, October 21, 2017 12:00 AM
Monday, October 23, 2017 12:00 AM
Wednesday, October 25, 2017 12:00 AM
Friday, October 27, 2017 12:00 AM
Sunday, October 29, 2017 12:00 AM
Tuesday, October 31, 2017 12:00 AM
Wednesday, November 1, 2017 12:00 AM
As you can see: There is only 1 day between the two last times.
So when I'm using freeformatter to describe the cronexpression it states:
At 00:00:00am, every 2 days starting on the 1st, every month
Well that is shown in the listed times above. But I need something that correctly fires every 2 days.
Tuesday, October 31, 2017 12:00 AM
Thursday, November 2, 2017 12:00 AM
and so on.
Apparently the simple trigger from quartz is not a real option for me!
It's becouse you misunderstood how cron expression works. For every month it will starts from first day of month. If it would work otherly, the next month wouldn't fit 1/2 part of expression.
For more detailed explanation, look here:
Quartz.net - Repeat on day n, of every m months?

Quartz cron trigger for every 2 weeks and 2 times a day ( 6 AM and 6PM)

I want to run a quartz job for every 2 weeks at morning 6'o clock and evening 6'o clock . how to achieve this .please advice.
I tried to schedule using below cron expression
01 01 1 1-0/14 01 ? *
but the next fire times are as below.
Sunday, January 1, 2017 1:01 AM
Sunday, January 15, 2017 1:01 AM
Sunday, January 29, 2017 1:01 AM
Monday, January 1, 2018 1:01 AM
Monday, January 15, 2018 1:01 AM
There are some kinds of date triggers cron is good at. Every N days is often not one of them. For instance, if you use something like this:
0 0 6,18 */14 * ?
You might get something like this:
Tuesday, March 29, 2016 6:00 AM
Tuesday, March 29, 2016 6:00 PM
Friday, April 1, 2016 6:00 AM
Friday, April 1, 2016 6:00 PM
Friday, April 15, 2016 6:00 AM
Friday, April 15, 2016 6:00 PM
As you can see, the 29th, followed by the 1st -- not exactly fourteen days apart.
It's useful to have something that lets you play with the expression and see the resulting dates. CronMaker can do that, if that's helpful.
However, since you say you are using Quartz, it supports other kinds of triggers, like DateIntervalTrigger that might be better suited for what you're looking for?

Resources