export scheduledFunctionPlainEnglish =
functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
})
或者更灵活的 cron 表格式:
export scheduledFunctionCrontab =
functions.pubsub.schedule('5 11 * * *').onRun((context) => {
console.log('This will be run every day at 11:05 AM UTC!');
});
Note that your project needs to be on a Blaze plan for this to work, so I'm leaving the alternative options below for reference.
If you want to schedule a single invocation of a Cloud Function on a delay from within the execution of another trigger, you can use 云计算任务 to set that up. 读读这篇文章 for an extended example of how that can work.
It is important to first note that the default timezone your functions will execute on is 美国/洛杉矶 according to the 文件. You may find a list of timezones here if you'd like to trigger your function(s) on a different timezone.