Search code examples
azurepysparkcrondatabricksazure-databricks

I would like to Create a schedule in Databricks that runs a job on 1st working day of every month


I would like to create a schedule in Databricks that runs a job on the first working day of every month (working days referring Monday to Friday).

I tried using Cron syntax but didn't have any luck. Is there any way we can schedule this in Databricks?. i don't want to use other Services like ADF to achieve this.


Solution

  • <second> <minute> <hour> <day of the month> <month> <day of the week> <year>

    So your are looking for day of the month value.

    0 0 0 1W * ?

    Explanation about the 1W. means the nearest weekday to the 1st of the month. If the 1st is a Saturday or Sunday, then the trigger will be on the 3rd.

    This bahviour changes when there is not a 1W but a 15W value. Then the trigger would behave differently. The trigger would fire on the 14th if the 15th is a Saturday. If the 15th is a Sunday then the trigger would fire on the 16th.

    So in order you are looking for the first day of the month you do not need to consider the weekend boundaries.