Reputation: 970
I am trying to populate a CRON expression that will pretend to be never executed(at least not in this life time).
I went through this SO question
https://stackoverflow.com/questions/8324306/cron-job-that-will-never-execute
But each expression in that question gives an exception
Microsoft.Azure.WebJobs.Host: Error indexing method 'Cleanup'. Microsoft.Azure.WebJobs.Extensions: The schedule expression '0 0 5 31 2 ?' was not recognized as a valid cron expression or timespan string.
What are the possible expressions that will fullfill the above mentioned expectation with regard to Azure Functions?
Thank you.
Upvotes: 3
Views: 4724
Reputation:
You cannot set never per algorithm, but a leap year with Saturday 29th gives a 28-year gap.
0 0 0 29 Feb Sat
as the first time around this will happen again is 2048.
Good enough?
Upvotes: 17
Reputation: 14324
Please check the Azure CRON expression, it's:
{second} {minute} {hour} {day} {month} {day-of-week}
And it uses the NCronTab library to interpret CRON expressions. In the github page you could find the value column can have a *
or a list of elements separated by commas. That means it doesn't support ?
.
So just change your expression to 0 0 5 31 2 *
it will be approved. And if you don't your function running you could just disable it. You could refer to this tutorial: How to disable functions in Azure Functions.
Update:
Due to the Function will calculate the Timer to get the function running time and the 2/30 and 2/31 will never come, then it will be in a loop calculation and the year will increase until beyond the limit 9999. In this situation the function will send a exception.
Upvotes: 7
Reputation: 768
The main format used for the scheduled WebJob
hence according to above rules your cron expression will leads to this error
instead of using 0 0 5 31 2 ?
use 0 0 5 31 2 *
Upvotes: 1