gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 12:09:21 25 4
gpt4 key购买 nike

每小时整点的 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 CRONexpressions"

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com