代码之家  ›  专栏  ›  技术社区  ›  MbaiMburu

Cron作业在firebase函数中不起作用

  •  0
  • MbaiMburu  · 技术社区  · 7 年前

    我有下面的cron工作,我需要每天早上6点和9点执行。

    cron.schedule('00 00 6,9 * * 0-6', function() {
    alertAllMembersWithAppointments();//executed everyday at 6 and 9AM});
    

    当我这样设定时间的时候

    cron.schedule('* * * * * *', function() {
        alertAllMembersWithAppointments();//executed everyday at 6 and 9AM
    });
    

    它工作正常,每分钟都在执行。请帮助设置时间,因为在我看来,node和linux的cron设置是完全不同的。我使用以下要求 const cron = require("node-cron");

    1 回复  |  直到 7 年前
        1
  •  2
  •   Frank van Puffelen    7 年前

    @sketchthat's comment isspot on with the logic here:每分钟运行cron作业,可能会使其处于函数的超时状态。

    但是,重新触发这样的功能将是不可靠的,除非你注意返回正确的承诺。如果你做的正确,它将工作,你最终有云功能,是永远活跃。在那一点上,找个便宜的节点主机会更便宜。

    对于可靠的基于时间的函数,您需要依赖外部触发器。看到了吗 Cloud Functions for Firebase trigger on time?

    推荐文章