I would like to create a schedule in databricks that runs every two weeks on monday night 0:00

Eelke van Foeken 0 Reputation points
2023-06-15T07:44:44.0033333+00:00

Hey

It seems that it is impossible to create a schedule in databricks that runs every two weeks on monday night 0:00. Or is it?

The best we can come up with is: 0 0 2 1,15 * ? *

Best regards,

Eelke van Foeken

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,534 questions
{count} votes

2 answers

Sort by: Most helpful
  1. PRADEEPCHEEKATLA 90,651 Reputation points Moderator
    2023-06-15T12:23:41.0766667+00:00

    @Eelke van Foeken - Thanks for the question and using MS Q&A platform.

    Unfortuantely, you can’t do it in one expression. How bout splitting it to two schedules? One for First Monday of the Month. 0 0 0 ? * MON#1 and Second for Second Monday of the Month 0 0 0 ? * MON#2 .

    It is possible to create a schedule in Databricks that runs every two weeks on Monday night at 0:00. The cron expression you provided, "0 0 2 1,15 * ? *", runs the job at 2:00 AM on the 1st and 15th day of every month. To modify this expression to run every two weeks on Monday night at 0:00, you can change it to "0 0 0 ? * MON#1 *" and "0 0 0 ? * MON#2 *".

    Here is a breakdown of the expression:

    • "0 0 0": This specifies the time of day as midnight.
    • "?": This specifies that the day of the month is not relevant.
    • "*": This specifies that the month is not relevant.
    • "MON#1": This specifies that the job should run on the first Monday of every month.
    • "MON#2": This specifies that the job should run on the second Monday of every month.

    For more details, refer to Run jobs on a schedule or continuously and Quartz Cron Syntax.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


  2. HomerAlpha 6 Reputation points
    2023-06-23T15:39:36.4966667+00:00

    Hi there,

    You are correct !!!!
    It is not possible to create a schedule in Databricks that runs every two weeks on Monday night at 0:00 that works for all months. This is because the number of Mondays in a month can vary between 4 and 5, as you mentioned.

    Option 1:

    Create two separate schedules in Databricks: one that runs on the first and third Monday of each month, and another that runs on the second and fourth Monday of each month. This way, you can ensure that your job runs every two weeks on Monday night at 0:00, regardless of the number of Mondays in a month.

    Option 2:

    You can create a monthly schedule that triggers on the first Monday of each month. Then, within your Databricks job or notebook, you can add logic to check if the current date falls within a 3-week interval from the third Monday of the month.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.