I want my Azure YAML pipeline to run on every last Sunday of the month at 4 AM. I currently have the following cronjob/schedule in my pipeline: current cron job
But this one runs every Sunday at 4 AM, which is way too often.
I have tried a couple of cronjobs already but none of them seem to do what I want:
- 0 4 25-31/1 * Sun
- 0 4 * 1-12/2 0
- 0 4 23-31/2 * Sun
- 0 4 25-31 1-12/2 0
I used Crontab.guru to check when these jobs will run. For example, 0 4 25-31 1-12/2 Sun, generates the following text: Crontab.guru description
To me it sounds like it will run based on two conditions:
- At 4 AM every day from the 25th till the 31st
- And on every Sunday of every 2 months from Jan till Dec, so every Sunday of January, March, May etc.
Is it even possible? Or does it require any scripting to implement this in an Azure YAML Pipeline?
Thank you!
Cron syntax does not support “last Sunday of the month” directly. You can add a script at the start of your pipeline that checks if today is the last Sunday of the month. If not, it exits the pipeline early. Here’s an example for your reference:
The pipeline will be triggered every Sunday at 4:00 AM UTC, but the steps you define will only be run on the last Sunday of each month.