简体   繁体   English

Firebase 云函数在 00 处触发

[英]Firebase Cloud Functions trigger at 00

Hei guys.嘿伙计们。 I was looking for a way to trigger my function every hour at 00 minute.我正在寻找一种方法来触发我的 function 每小时 00 分钟。 The way it works now it depends by the time the function has been uploaded at, so if I upload it at 13:45, it will first trigger at 14:45.它现在的工作方式取决于function上传的时间,所以如果我在13:45上传,它将在14:45首先触发。 What should I do to make it trigger at 14:00?我应该怎么做才能让它在 14:00 触发?

You should use the (new) feature that allows scheduling Cloud Functions by using functions.pubsub.schedule().onRun() .您应该使用允许使用functions.pubsub.schedule().onRun()调度 Cloud Functions 的(新)功能。

In your case you would use a Unix Crontab configuration as follows:在您的情况下,您将使用Unix Crontab 配置,如下所示:

exports.scheduledFunctionCrontab = functions.pubsub.schedule('0 * * * *')
  .onRun((context) => {
  console.log('This will be run every hour at hh:00');
  return null;
});

See a crontab configurator here: https://crontab.guru在此处查看 crontab 配置器: https://crontab.guru

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM