Loreno
Loreno

Reputation: 668

Run Azure Function every 3 days

I want to create a cron expression to run Azure Function every 3 days at 12:00 PM

I created this: 0 0 */72 * * * From my understanding, it should make the function run every 72 hours. When I run my function locally I see: enter image description here

Looks like function will be run everyday. What's wrong? How to specify also the time at which function will start (12:00 PM)?

Upvotes: 1

Views: 1210

Answers (2)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 29950

Update: as per @markxa mentioned, it will run at 12:00pm every 3rd day of the month. Please use this: 0 0 12 1/3 * *.

Test result as below: enter image description here

Upvotes: 3

MarkXA
MarkXA

Reputation: 4384

Unfortunately the */72 doesn't mean "every 72 hours", it essentially means "when the hour modulo 72 is zero" which is only true when the hour itself is zero. The nearest you can get with a standard expression is 0 0 12 */3 * * which will run at 12:00pm every 3rd day of the month. Unfortunately this will give you a gap that's not 3 days at the end of any month that doesn't have 30 days; if that's not acceptable then you'll have to run it every day with 0 0 12 * * * and keep the last run time in persistent storage somewhere in your function code so you can only actually do the processing every 3 days.

Upvotes: 2

Related Questions