如何在大约每整小时 运行 的 firebase 中安排一个函数?

How to schedule a function in firebase that is run approximately every full hour?

firebase 文档解释了如何将函数配置为运行每 5 分钟。我想 运行 每隔 整整一小时 相当精确地执行一个函数。我可以轻松地将它安排为每小时 运行 一次,但是怎么可能在整点 运行、8:00、9:00、....

我准备好它会 运行 大约在整点。

不要使用英文描述时间表,而是使用所谓的
“unix-cron 字符串格式”(* * * * *) 您可以在其中指定时间表的确切(或重复)分钟、小时、天、月或星期几。

此 link 用于“配置 cron 作业计划”:https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules

这篇文章解释了它们:英文描述和 unix-cron 字符串格式:https://firebase.googleblog.com/2019/04/schedule-cloud-functions-firebase-cron.html

最终你的函数应该是这样的:

exports.testFunction = functions
     .pubsub.schedule('0 * * * *') // every hour at the 0 min, every day, every month 
     .onRun(...//the code to run);