cit*_*kid 3 firebase google-cloud-functions
firebase 文档解释了如何将函数配置为每 5 分钟运行一次。我想每隔一小时相当精确地运行一个函数。我可以轻松地将其安排为每小时运行一次,但是如何让它在整点(8:00、9:00,...)运行?
我准备它只会在大约整点运行。
小智 9
不要使用时间表的英文描述,而是使用所谓的
“unix-cron 字符串格式”(* * * * *),您可以在其中指定精确的(或重复的)分钟、小时、天、月或星期几。日程安排。
“配置 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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4568 次 |
| 最近记录: |