我可以在每个小时的特定时间在 Google Apps 脚本上设置每小时触发器吗? [英] Can I set an Hourly Trigger on Google Apps Scripts for a Specific Time During Each Hour?

查看:27
本文介绍了我可以在每个小时的特定时间在 Google Apps 脚本上设置每小时触发器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个链接到谷歌表格文档的谷歌应用程序脚本.我想在每个小时的顶部运行脚本,即正好在下午 1:00:00、下午 2:00:00、下午 3:00:00 等.

我在管理项目的触发器"设置中设置了每小时触发器.但是,这将选择一个小时内的随机时间来运行脚本.例如,它可能在下午 1:15 或下午 1:56 运行.它仍然每小时运行一次,但当时间改变时我需要它.

是否可以从脚本代码中设置触发器,使其按我的意愿运行,而不是在每个小时内随机运行?

提前致谢!

解决方案

是的.尝试 ClockTriggerBuilder 方法中的 nearMinute 选项,如文档所述

虽然仍然不是精确",但如所示,它应该是正负 15 分钟.

希望这会有所帮助!

I have a google apps script that is linked to a google sheets document. I want to run the script at the top of each hour, ie, exactly 1:00:00 pm, 2:00:00 pm, 3:00:00 pm etc.

I have set up hourly triggers from within the "Manage Project's Triggers" settings. However this will choose a random time during the hour to run the script. For example, it may run at 1:15pm or 1:56pm. It still runs once an hour, but I need it right when the hour changes.

Is it possible to set up a trigger from within the script's code such that it will run as I want, rather than a random time during each hour?

Thanks in advance!

解决方案

Yes. Try the nearMinute option from the ClockTriggerBuilder method as documented here.

While it still wouldn't be 'exact', as indicated, it should be plus or minus 15 minutes.

Hope this helps!

这篇关于我可以在每个小时的特定时间在 Google Apps 脚本上设置每小时触发器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆