[英]How do I make set a google script trigger to run again if there is an error?
I have a google sheet to keep stack of live stock prices and portfolio valuations. 我有一个Google工作表来保存实时股票价格和投资组合估值。 Also, I have some script which runs once a day to provide a permanent record of the valuation.
另外,我有一些脚本每天运行一次,以提供永久的估值记录。 However, sometimes the stock prices do not load immediately, so the permanent record contains errors.
但是,有时股票价格不会立即加载,因此永久记录中包含错误。 What is the best way of fixing this ?
解决此问题的最佳方法是什么? For example, can I set a trigger to repeat after 30 minutes if there are errors in certain cells ?
例如,如果某些单元格中有错误,我是否可以将触发器设置为在30分钟后重复执行?
I did try a loop to repeat the process within the script if there was an error, but as the maximum time google script can run for is about 5 minutes, it is not effective. 如果发生错误,我确实尝试了一个循环以在脚本内重复该过程,但是由于google脚本可以运行的最长时间约为5分钟,因此无效。
One possible solution is to set up a control sheet with two variables: 一种可能的解决方案是设置带有两个变量的控制表:
Trigger One: trigger a script first thing in the morning to set the "Has the script run today" value to 'False'. 触发一个:早上首先触发脚本,以将“今天运行脚本”值设置为“ False”。
Trigger Two: trigger a second script (say) every hour to check if 触发二:每小时触发第二个脚本(例如)以检查是否
You could run Trigger Two more or less frequently depending on how many iterations it takes to get rid of all the errors. 您可以或多或少地频繁运行触发器2,具体取决于消除所有错误所需的迭代次数。
But do remember that there is a quota for the total trigger run time as well: 90 min per day for a consumer account . 但请记住,总触发运行时间也有一个配额: 消费者帐户每天90分钟 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.