-1

I'm trying to schedule a job to trigger on the first Monday of each month:

This is the cron expression I got: 0 5 1-7 * 1 (which ,as far as I can read unix cron expressions, triggers at 5:00 am on Monday if it happens to be in the first 7 days of the month)

However the job is triggered on what seems to be random days at 5:00 am. the job was triggered today on the 16 of Aug!

Am I reading the expression awfully wrong? BTW, I'm setting the timezone to be on AEST, if that makes difference.

Ademi
  • 320
  • 2
  • 12
  • 1
    Check out the [answers](https://superuser.com/questions/428807/run-a-cron-job-on-the-first-monday-of-every-month) on superuser.com – jabbson Aug 15 '21 at 23:56
  • 1
    You can check [here](https://crontab.guru/#0_5_1-7_*_1) what your cron expression really means. – Benjamin W. Aug 16 '21 at 00:05
  • @jabbson , well that's an interesting behavior. Sadly GCP will not let me input anything but a cron expression. It's time to wrap the scheduler in the logic instead. – Ademi Aug 16 '21 at 00:10
  • 1
    @BenjaminW. I used crontab guru to come up with the expression, but apparently there is a caveat in the situation I'm describing. Check Jabbson comment if you're interested – Ademi Aug 16 '21 at 00:10

1 Answers1

1

You can use the legacy cron syntax to describe the schedule.

For your case, specify something like below:
"first monday of month 05:00"

Do explore the "Custom interval" tab in the provided link, to get better understanding on this.

Gourav B
  • 864
  • 5
  • 17