Der*_*nce 2 cron firebase google-cloud-functions google-cloud-scheduler
我有一个计划的云功能(使用Google 的新解决方案),计划在每周一凌晨 12:00 运行。
export const updateHighScores = functions.pubsub.schedule('0 0 * * 1').onRun((context) => {
// (code)
// console.log(‘This code will run every Monday at 12:00 AM UTC’);
});
Run Code Online (Sandbox Code Playgroud)

我原以为它会在 UTC 时间凌晨 12:00 运行;然而,当午夜 UTC 到来时,什么也没发生。所以我上床睡觉,为我预定的云功能不起作用而感到难过,但决定继续努力。
但是第二天我检查了日志,看起来它确实有效,但它在太平洋时间上午 12:00 运行。

知道为什么这在太平洋时间午夜而不是 UTC 运行吗?
(我将通过更改所有这些变量并观察它如何影响预定的云函数来进行大量猜测和检查,但如果有人知道的话,我不妨在这里问一下。谢谢! )
调度函数在Google Cloud Scheduler调度的时候触发。使用 Firebase CLI 进行部署时,会自动为您创建 Cloud Scheduler 中的条目。如果您点击Cloud 控制台以显示您的日程安排,您会看到时区设置为“美国/洛杉矶”,即 PST。
时区是使用函数构建器 API 设置的。您可以在文档中阅读相关内容。
我做这样的事情
exports.scheduledFunction = functions.pubsub
.schedule("0 4 * * *")
.timeZone("Asia/Baku")
.onRun((context) => {
groupCustomers.set({});
tables.set({});
calledCustomers.set({});
groups.set({
A: { name: "Altering", activeOnTablet: false },
});
return null;
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2448 次 |
| 最近记录: |