Running APScheduler job the day before the 1st and 3rd Monday each month - apscheduler

I have an APScheduler job that creates a report our client has requested for the first and third Mondays of the month.
To deliver that in time, I want to run the job the day before the first and third Monday, which can't be specified directly in APScheduler.
I noticed another user had this question as well, describing the request as impossible, in the comments of Running APScheduler Job Every nth Day of Month

Here's how I solved it:
scheduler.add_job(func, 'cron', 'day_of_week'='sun', 'day'='last,1-6,14-20')
By specifying the day of the week, and then specifying the days in the month that could apply, it will fire the day before the first and third Mondays. It only fires when all the conditions are met, so the other dates (which won't be Sunday) don't fire.

Related

How to schedule biweekly SSRS subscription on 2017 report server

I would like my report to be sent biweekly on a Monday. Right now, I created two different subscriptions that sends the report on every 2nd and 4th week. I am not sure it would be accurate considering, I would like the send the report Monday after Pay period ends. What's a best way to approach to this?
A subscription can be created by Week and scheduled to repeat after 2 weeks. Monday can be selected as the day.
The schedule will show Every Monday of every two weeks.

Reoccurring SQL job to run on the 2nd and 4th Thursday of every month

I need a job to run on the 2nd and 4th Thursday of every month. I know I can set up a job to run every two weeks but that logic doesn't work when a month eventually hits a five week span. Is it possible to set this up using the SQL Server Agent Schedule? If not, does anyone recommend another method?
Create two schedules on the job, one that runs on the second Thursday, and one that runs on the fourth.
Under the Frequency heading on the Scheduler, change the Occurs drop down to Monthly to get to the options you need.

BigQuery UI - How to schedule a query to run on the last day of the month?

I have a query that pulls a summary of metrics for the past month that needs to run on the last day of each month at a set time.
The BigQuery 'Schedule query' UI allows you to choose a date and time to run a query each month but there is no apparent option to choose that last day of the month.
If I simply choose the 31st of the month, what happens if there are only 30-days in that month? Will the query still run?
Or do I have to schedule a query to run on the 27th, 28th, 29th, 30th, 31st of the month to make sure that I don't miss the correct date?
I can't find any mention of this situation in the BigQuery documentation or online so any help/suggestions will be very gratefully received.
I understand that you need to run your query in the last day of each month. However, if you set 31st of the month as the schedule options, it will skip the months which do not have 31 days.
You can check this affirmation, by performing the following test in the BigQuery UI:
In the Schedule query options, under Schedule options, set:
Repeats: Monthly
On the: 31
Start date and run time: set the date to 10th of June (which is a month with 30 days)
Click Schedule
On the left side of the BigQuery UI, click on Scheduled queries
Check the query you saved. Among other details, it should be displayed Next Scheduled.
It will be shown July, 31
As you can see, it skipped the 30th of June. Thus, when you configure your query to run on the 31st of each month, it will ignore the months with less than 31 days. For this reason, I would advise you to select 27th, 28th, 29th, 30th, 31st of each month in order to run it in a manner that suits you.
As a bonus information, you can set up a Custom schedule option, as mentioned here. You can use syntaxes as "1st monday of month 00:00" or "every monday 00:00", here.

Recommendation on how to store an event period

OK, let's say I am writing a calendar application in which a user can create an event. An event can occur in the following situations:
1 time only.
Every Period of time keep reply, until a day.
Every Period of time keep reply, until a day, except some days.
Every some kind of week day.
Let me explain in a detailed example:
1 time only: 24/8/2011 ONLY.
Every Period of time keep reply, until a day: 25/8/2011 Start, and every week end will have this event, until 30/10/2011.
Every Period of time keep reply, until a day, except some days: 25/8/2011 Start, and every week end will have this event, until 30/10/2011, except the 10/09/2011 and 17/09/2011.
Every some kind of week day, .
Every some kind of week day, except some days.
Martin Fowler wrote a nice big article about just this topic a few years ago. Rather than repeat his analysis, I'll just point you at the pdf. It's called Recurring Events For Calendars.

Autosys monthly job schedule

I know how to run autosys job on certain day in a week but how can i run once in a month.. like if i have to run job1 on 2nd day of the month .. any help would be good for me.. thank you
You can specify a day of the month with an extended calendar with the condition MNTHD#nn, where nn is the nnth day of the month.
The extended calendar can be defined like
extended_calendar: second_of_month
condition: MNTHD#2
and you can include the calendar as the run_calendar attribute of your job like
insert_job: job1
run_calendar: second_of_month
Find more information here on the different conditions for an extended calendar.
Use a run calendar. Create a calendar with the days you want the job to run on and add that calendar to the job. The current version of Autosys, R11 allows you to use logic to create calendars. For example the first business day of the month.