javascript - 从每个 00 :x0 之前 1 秒开始,每 10 分钟运行一次 Azure Function

标签 javascript cron azure-functions

Azure 函数必须从 00:59:59(小时、分钟、秒)开始无限期地每 10 分钟运行一次。我使用的 cron 计划不成功。

我正在使用基于计时器的 Javascript Azure 函数,例如,

module.exports = async function (context, myTimer) {
    var timeStamp = new Date().toISOString();

我不认为 Azure 函数中有用于设置开始日期/时间的设置。 cron 调度程序似乎是唯一的选择。

根据 Azure Functions 文档:

The schedule expression is a CRON expression that includes 6 fields:

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

Note that many of the cron expressions you find online omit the {second} field, so if you copy from one of those you'll have to adjust for the extra field.

文档提供的示例:

To trigger once every 5 minutes: 0 */5 * * * *

To trigger at 9:30 AM every day: 0 30 9 * * *

59 */10 * * * *结果是这些执行时间:

  • 结果:1​​1:40:59 |期望时间:11:39:59
  • 结果:1​​1:30:59 |期望时间:11:29:59
  • 结果:1​​1:20:59 |期望时间:11:19:59
  • 结果:1​​1:10:59 |期望时间:11:09:59

59 */10-1 * * * *不支持。

Azure Function 需要在 00:59:59 开始初始运行的原因是该函数将前 10 分钟内发生的事件时间戳与 10 分钟 UTC 时间间隔进行比较。如果分钟级别的任何事件时间戳与分钟级别的间隔内的 UTC 时间戳相匹配(例如, 2018-12-21Txx:3x:xx.xxxZ 处的事件的 2018-12-21T00:35:18.894Z 与此模式的任何 UTC 时间戳 2018-12-21Txx:3x:xx.xxxZ 匹配),则执行操作。 )

我被困住了。任何帮助表示赞赏。谢谢。

最佳答案

有点拗口,但你想要的是59 9,19,29,39,49,59 * * * *

关于javascript - 从每个 00 :x0 之前 1 秒开始,每 10 分钟运行一次 Azure Function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53916782/

相关文章:

javascript - Javascript 'for-in' 函数是否只返回一个索引?

javascript - 从单独的文件加载 underscore.js 模板

cron - 在主机中运行 cron 不到一分钟

http - 我将如何使用 cron 作业发送 HTML GET 请求?

php - PHP逻辑每日更新

azure - 如何在 Azure 函数中手动将调用标记为失败?

javascript - 如何更新代表相同数据的两个不同的 React 组件实例?

javascript - json、rails、javascript 中的解析错误

c# - 构建 Azure Function v3 时无法解析程序集 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.0.0"

node.js - 如何在Azure Function上管理数据库驱动程序