Dan*_*yen 1 .net c# cron expression hangfire
我正在使用Hangfire工作.
我有一个功能需要在两个时刻之间运行.
EX:开始时间:8:13结束时间:21:32间隔:15分钟.
每天跑步.
这个要求的"表达"是什么?
Hangfire使用cron(tab)表示法.
您需要将任务添加三次:
13-59/15 8 * * *
*/15 9-20 * * *
0-32/15 21 * * *
Run Code Online (Sandbox Code Playgroud)
使用它:
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 * * *");
Run Code Online (Sandbox Code Playgroud)
第一行表示在13和59分钟之间,第8小时,每15分钟运行一次.
第二行表示9至20小时,每15分钟运行一次
第三行表示分钟0-32,小时21,每15分钟运行一次.
| 归档时间: |
|
| 查看次数: |
1394 次 |
| 最近记录: |