【问题标题】:Can I use the Google App Script trigger more often than every minute?我可以比每分钟更频繁地使用 Google 应用脚本触发器吗?
【发布时间】:2022-01-05 13:26:07
【问题描述】:

Google 应用脚本让您可以轻松触发脚本,甚至每分钟都可以。但是,我想每 15 秒触发一次事件?我可以轻松做到吗?

或者也许其他公司提供易于配置的类似工具?

【问题讨论】:

  • 您可以启动一个侧边栏并设置一个 setInterval 并让它每 15 秒触发一次调用您的服务器端函数,只要客户端对话框保持活动状态。
  • 在这里寻求软件推荐是题外话。试试Software Recommendations。关于更快的 Google Apps 脚本触发频率,这是不可能的,但有很多选择。如果您需要有关 Cooper 建议或 Dmitry 答案的更多详细信息,请edit 该问题以提供有关您的用例的更多详细信息。

标签: google-apps-script automation triggers cron


【解决方案1】:

目前这是不可能的。但是,您可以让父函数以 15 秒的延迟运行子函数 4 次,例如:

// This is the function that gets triggered by your trigger every minute
function parentFunction() {
  for(let i = 0; i < 4; i++) {
    childFunction();
    Utilities.sleep(15000); // sleep for 15 seconds
  }
}

function childFunction() {
  // this function does whatever you need
  // 4 times per every trigger execution
  // which is 4 times per minutes or every 15 seconds
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-08
    • 1970-01-01
    • 1970-01-01
    • 2021-05-14
    • 1970-01-01
    • 1970-01-01
    • 2021-09-13
    相关资源
    最近更新 更多