Marcus
Marcus

Reputation: 8669

Azure WebJob not accepting a valid(?) CRON expression

I used crontab.guru to create a very simple CRON expression with the desired behavior to execute every day at 3:15 (AM) and this is the result: 15 3 * * *

Crontab.guru

Unfortunately for me, in Azure Portal this does not work, but if I add a leading 0 to my expression as such, 0 15 3 * * *, Azure will accept it, while crontab.guru will tell me it is wrong. The specification according to crontab.guru is: minute hour date month weekday.

Azure does not accept my CRON expression

Azure accepts the expression with a leading zero

The questions..

Upvotes: 25

Views: 11870

Answers (1)

Thomas
Thomas

Reputation: 29746

Have a look at the documentation:

The NCRONTAB expression is composed of 6 fields: {second} {minute} {hour} {day} {month} {day of the week}. A CRON expression has only 5, without the seconds.

So the first 0 describes the seconds.

*    *    *    *    *    *  command to be executed
┬    ┬    ┬    ┬    ┬    ┬
│    │    │    │    │    │
│    │    │    │    │    │
│    │    │    │    │    └───── day of week (0 - 7) (0 or 7 are Sunday, or    use names)
│    │    │    │    └────────── month (1 - 12)
│    │    │    └─────────────── day of month (1 - 31)
│    |    └──────────────────── hour (0 - 23)
│    └───────────────────────── min (0 - 59)
└────────────────────────────── second(0 - 59)

Upvotes: 29

Related Questions