鉴于您正在调用多个函数,我建议您创建一个触发器,而不是使用
ScriptApp.newTrigger
,这可以通过引入另一个函数来触发,该函数检查脚本是否已超过预定的执行时间(如果最大值为6,则可以将其设置为5以确保安全)。
指的是这样的事情-
// var today = new Date();
// 'today' is declard in the original script
function isTimeUp(today) {
var now = new Date();
return now.getTime() - today.getTime() > 30000;
// 30000 = 30 seconds; this is the threshold limit
// you are free to setup your own threshold limit
}
here
.timeBased()
触发但是,您可以使用不同类型的触发器。