1
votes

Currently I have a function deployed in Google Functions, which is triggered by a Cron Job using Cloud Scheduler in Google Cloud Platform.

The Cron Job Frequency in unix is the following: 0 9 1-7,15-21,29-31 * 1

Which means that it should be triggered every Monday in a Month at 9:00 AM, which day falls between 1st and 7th, 15th and 21st, 29th and 31st, respectively. Or in other words, it gets triggered every 2 weeks.

The following image (cron job testers) also confirms what I am intending to do.

https://lh3.googleusercontent.com/-f1RNnvdj_ww/YFC_WDxKSSI/AAAAAAAAAcY/_YVdgq2mxyksZHDJRQ_4m9jMylw8G2IEwCK8BGAsYHg/s0/2021-03-16.png?authuser=0

As expected, yesterday March 15th (Monday) it got triggered, however today March 16th (Tuesday) it got triggered as well

I am wondering if this has happen to any of you and whether it's a problem with my cron job or either Google Cloud Scheduler doesn't interpret it this way.

Any help/experience is highly appreciated!!

1

1 Answers

3
votes

Crontab uses OR when both day of month and day of week are provided: please, see your screenshot, it shows that your process will run tomorrow, March 17th, at 9:00.

I honestly do not know the actual reason of this crontab exception: for curiosity, I came across this SO question, which provides a possible explanation.

In order to express similar conditions, in a general use case, you can take advantage of crontab expressions, see for example this SO question or this other in Server Fault, but I do not know whether they are or not applicable in Google Cloud Scheduler.

Perhaps, instead of a cron expression, you can use the so-called English Style Schedule, the same used on App Engine - see the tab Custom interval, to define your expressions, maybe it can be more suitable for your use case.