0
votes

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

1

1 Answers

0
votes

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.