Azure定时器触发器: Cron expression for every hour on the hour

标签 azure cron azure-functions timer-trigger

每小时整点的 cron 表达式是什么? 我试过这个'0 0 *? * *' 但它抛出了一个错误 我有一个 Azure 函数计时器触发器

下面的表达式每分钟运行一次。

public static void Run([TimerTrigger("0 * * * * *")]TimerInfo myTimer, TraceWriter log)

这是我在尝试“0 0 * ? * * *”和“0 0 * ? * *”时收到的错误

[11/22/2018 12:45:29 AM] A ScriptHost error has occurred [11/22/2018 12:45:29 AM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Currencies.Run'. Microsoft.Azure.WebJobs.Extensions: The schedule expression '0 0 * ? * * *' was not recognized as a valid cron expression or timespan string. [11/22/2018 12:45:29 AM] Error indexing method 'Currencies.Run' [11/22/2018 12:45:29 AM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Currencies.Run'. Microsoft.Azure.WebJobs.Extensions: The schedule expression '0 0 * ? * * *' was not recognized as a valid cron expression or timespan string.

最佳答案

编辑:尝试使用“0 0 * * * *”doc强调六个字段的使用。

Azure Functions uses the NCronTab library to interpret CRON expressions. A CRON expression includes six fields:

{second} {minute} {hour} {day} {month} {day-of-week}

<小时/>

Azure 据称使用 NCrontab根据 doco 的库,但测试表明并非如此! 因此请使用“0 * * * *” 表示每小时的整点。

这是LINQPad验证脚本:

var s = CrontabSchedule.Parse("0 * * * *");
var start = new DateTime(2000, 1, 1);
var end = start.AddYears(1);
var occurrences = s.GetNextOccurrences(start, end);
occurrences.Dump();

[这需要引入 NCrontab nuget 包]

引用号:https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer

"Azure Functions uses the NCronTab library to interpret CRON expressions"

关于Azure定时器触发器: Cron expression for every hour on the hour,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53422398/

相关文章:

python-2.7 - 在谷歌应用引擎中运行 cron 并登录 :admin in app. yaml 时出现错误 302

cron - 如何让 cron 删除超过特定大小的文件

azure - 计时器触发的Azure函数不规则执行

c# - 使用 OpenAPI 启动 HttpTrigger 时主机尚未启动

azure - 如何在成功部署 Azure 模板时从事件网格获取事件

Azure 数据工厂与数据同步

node.js - 如何在服务器端的node.js中设计每天执行的常规作业?

node.js - 如何在 Azure Function App 中禁用自适应采样

azure - 使用应用程序密码获取 AD 用户列表的方法

azure - 在失败的任务上继续 Azure Pipeline