Reputation: 83
I'm using Hangfire for jobs.
I have a function need run between two moment.
EX: Start time: 8:13 End time: 21:32 Interval: 15 minutes.
Run everyday.
What is the "expression" for this requirement?
Upvotes: 3
Views: 2833
Reputation: 27357
Hangfire uses cron(tab) notation.
You'll need to add the task three times:
13-59/15 8 * * *
*/15 9-20 * * *
0-32/15 21 * * *
Using it:
RecurringJob.AddOrUpdate(() => Console.Write("MyJob!"), "13-59/15 8 * * *");
RecurringJob.AddOrUpdate(() => Console.Write("MyJob!"), "*/15 9-20 * * *");
RecurringJob.AddOrUpdate(() => Console.Write("MyJob!"), "0-32/15 21 * * *");
First line says between the minutes of 13 and 59, for hour 8, run every 15 minutes.
Second line says for the hours 9 - 20, run every 15 minutes
Third line says for the minutes 0-32, for hour 21, run every 15 minutes.
Upvotes: 7