How to create a schedule which can go to next year


I am trying to create a schedule which get triggers every 6 months.

Here are some examples I tried,

Example 1:
Every 6 months from today
So start month is month of today (March) & end month is 6 months from today (September)
This works fine

Example 2:
Every 6 month from October 1st
So start month is October & end month is April
This fails with the error
INVALID_ARGUMENT: Invalid schedule spec: invalid calendar spec: Month End is before Start or not in range [1-12]

As I understood Start month October & end month April cause the error.

To solve this, I tried to include
Start month = October
Start year = 2023
End month = April
End year = 2024

But I am getting the same error.

Can you help me solve this issue?

Hi @ddd

Setting a cron expression and remaining runs should work

    Schedule schedule =
                            "0 0 1 */6 *")) // "At 00:00, on day 1 of the month, every 6 months"
                        .setRemainingActions(2) // only two times 


Thanks for the reply. I think I managed to achieve that by doing something like


Hopefully it works.

But thanks for your solution too

1 Like