Google 脚本 运行 ClockTrigger 多个脚本

Google Script Run ClockTrigger Multiple Scripts

我的情况是这样的:

  • a google form signup where people can sign up for notifications
  • a series of scripts that I would like to run nightly that looks through the form responses and emails people appropriately, Emailer()
  • an unsubscribe script that ideally runs frequently (every hour or so would be enough) as well as right before the notifications email is sent. This looks through the inbox for emails and removes the appropriate entries from the form responses, Unsubscriber()

我无法想出一种方法来协调这两个脚本 运行 的方式。我想要发生的是全天每小时左右取消订阅者()运行。在午夜或某个深夜时间,我想 运行 Emailer() 一次并且此时 Unsubscriber() 函数不 运行ning。一旦 Emailer() 完成,我希望 Unsubscriber() 函数以固定间隔恢复 运行ning。我觉得这应该可以使用 ClockTrigger,但我无法想象如何实现它。

我也想知道,如果 Unsubscriber() 函数计划 运行 每小时使用 ClockTrigger,但在某个实例上花费的时间超过一个小时,ClockTrigger 是否会启动第二个实例脚本?

Here是关于如何手动创建时间触发器的文档,您可以将函数设置为每小时运行。

此触发器可能与一个主函数相关,您可以在该函数中计算当前时间,如果它在午夜范围内(例如中午 12 点 < 当前时间 > 凌晨 1 点),则每隔一段时间调用函数 Emailer()当天调用 Unsuscriber()。

希望对您有所帮助。