1

Good afternoon, my friends, I would like to inform you that I am Brazilian so I would like to apologize for my English.

I have an azure webjob and want to set it to run every 15 minutes.

I'm deploying my webjob using Visual Studio and I already have my settings.job file. My problem is that when I set up to run every three minutes, it works perfectly, but when I set it to run every fifteen minutes, it works only minutes 0,15,30,45.

I hope you have managed to understand me

This is how my settings.job file is:

{ "schedule": "* */15 * * * *" }
  • 1
    Isn't 0, 15, 30, 45, ... every 15 minutes as you expected? – David Ebbo Sep 28 '17 at 18:23
  • I'm sorry, I must have expressed myself badly, what I meant, is that it runs at "full" times, for example, 15:00 - 15:15 - 15:30 -: 15: 45. And what I want is for it to run regardless of the time, for example, 15:03 - 15:18. – Miguel Patreze Sep 28 '17 at 18:32

3 Answers3

7

The semantic of cron expressions is that they are absolute in term of time. So when you have 0 */15 * * * *, it means run at exactly 0 minutes after the hour, 15 minutes after, etc... There is no way to make it start from an arbitrary time.

You wrote when I set up to run every three minutes, it works perfectly, but the behavior should be the same there: 0, 3, 6, 9, ...

As an aside, note that your cron expression is not quite correct. Instead of * */15 * * * *, it needs to be 0 */15 * * * *. Otherwise, it will run every second for a whole minute, every 15 minutes.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
7

So a CRON expression is composed of six fields -> {second} {minute} {hour} {day} {month} {day of the week}

Thus, to run a job every 15 minutes, it should be something like -> 0 */15 * * * *

Here's a reference: https://learn.microsoft.com/en-us/azure/app-service/web-sites-create-web-jobs#cron-expressions

Hope this helps!

Kent Aguilar
  • 5,048
  • 1
  • 33
  • 20
1

You can use a TimeSpan expression as well, which I find it quite easier to understand:

public async static Task SomethingAsync(TimerTrigger("00:15:00", RunOnStartup = true, UseMonitor = true)] TimerInfo timer)

Where "00:15:00" is "every 15 minutes" as TimeSpan.FromMinutes(15).ToString() says.

This requires you to use Microsoft.Azure.WebJobs.Extensions NuGet which you have to be careful to match your Microsoft.Azure.WebJobs version.

Gonzo345
  • 1,133
  • 3
  • 20
  • 42