Airflow pipeline schedule - cron

I am trying to run a pipeline on a schedule where it runs on a certain weekday where n number of weekdays have already been elapsed? For example, I want to run it on Monday(weekday, may 16 2022) where we have already passed 10 weekdays in the month of May. Similarly for other months, I would like to run it on a Monday where we have crossed 10 weekdays before that Monday and so on.
I tried various ways but nothing worked the way I want. Is there a way to keep a count of weekdays while scheduling the airflow pipeline?

Related

Cron expression to run everyday but not on a window

Is it possible to create an expression for quartz scheduler in java which runs the job every 15 minutes but should skip the job runs from Saturday night 9PM to Sunday morning 6AM? So it will be like the job will run all 7 days a week every 15 minutes but should not run from Saturday 9PM to Sunday 6AM (for some maintenance activity at that time).
You can use a Quartz Calendar to exclude certain days and/or time periods. To support your use-case, you have two choices:
Implement a custom calendar by implementing the org.quartz.Calendar or extending org.quartz.BaseCalendar. Internally your custom calendar can use two CronCalendar implementations described below.
Use two "chained" CronCalendars. By chaining, I mean using one calendar as the base calendar of the other calendar. The first calendar will exclude Saturdays 9pm to midnight, the second will exclude Sundays 00am to 6am. These are the cron expression used by these two calendars:
21-23 ? * SAT
00-05 ? * SUN
Here are a few examples showing how to use calendars in your code:
http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-04.html
https://www.javarticles.com/2016/06/quartz-calendar-example.html

How to schedule a Cron job for multiple days every month?

I wish to schedule a airflow job for specific set of dates every month, for example 11th and last day of every month and used the below scheduler expression
25 14 11,L * * # At 2:45 pm on 11th and last day of every month
When I validated the above in https://crontab.guru/ and http://cron.schlitt.info/ i was told the expression as invalid.
Is it possible to schedule together for a known and a unknown (here last) day of every month? If not is there any other way to achieve this?
maybe your cron does not support the "L" flag. you can refer to this CRON job to run on the last day of the month

CRON expression to start every 9th of month excluding weekend

I have to schedule a job to run every 9th of the month. and if 9th falls in weekend then in should run on next monday
for example
feb 9th is sunday so it should run on feb 10th i.e. next working day.
This kind of logic won't be possible entirely from your crontab schedule. I'll also point out the possibility that Monday might not necessarily be the "next working day" (think of holidays for example) in which case you might want to account for that as well.
If you will always choose Monday when the 9th is on a weekend (regardless of that Monday being a real working day, you can schedule your cron job to run on the 9th, 10th, and 11th of every month. For example, this would run on the 9th/10th/11th at 8am every month:
* 8 9-11 * 0 your_script
After that, the logic to determine if tasks need to run will have to be handled within the script itself. If you're using Python for example:
import datetime
today = datetime.date.today()
weekday = today.weekday()
if weekday is 5 or weekday is 6:
print("it's the weekend, do nothing")
elif today.day is 9 or (today.day is not 9 and weekday is 0):
print("run the script on the 9th or the first Monday after the 9th")
else:
print("this should not happen")
(Note that the script would run on every single Monday with this logic, but if you set up the cron job only to run on the 9th/10th/11th of the month then it will work just fine)
I really hope this helps!

Odoo12 Cron Jobs Execute on specific days

I have written cronjobs in odoo12 and I want them to execute 6 days in a week with exemption of sundays since sunday is not a working day, how can i do that in odoo12/odoo11
You can do one thing run cron everyday but while executing the function you can skip there put condition there of not executing your function on sunday.

cron expression for quartz to start on particular month and repeat every months onwards

I am working on Quartz Scheduler where need to trigger my job on basis of monthly where user can select desired month date from which he want to make it run for every month on that particular date. lets say- I want to schedule quartz job from August 20,2015 which should run every month on 20th, but it should not start by today,must be start on August 20,2015 onward. what would be the cron expression for this?
I have tried a lot to find out the matching thread but did not worked for me.
like if i have to make for every month which start on 20 May 2015 and repeat every 20th date of month the cron expression would be [0 0 12 20 1/1 ? *].for this requirement lot of things available around and works nicely. but how to schedule Quartz which must fire on particular date and repeat onward for every month on that particular date and time?
Please help me out.any link or any guideline would be appreciable.

Resources