I have an Apps Script that constantly gets this error. Judge by the notification email, it looks like the time limit is 5 minutes. Does anyone know if there is a way to extend this time limit? Or perhaps is there a way to call the Apps Script again and it pick up from where it left off? Any help is appreciated.
相关问题
- How can I force all files in a folder to be owned
- Google Apps Script: testing doPost() with cURL
- Google Apps Script to turn in, grade, and return a
- Script fails on SpreadsheetApp.openById - Requires
- Split Lines and Bold Text within a ui.alert Window
相关文章
- How to allow access for importrange function via a
- Google app script trigger not working
- Set Date/Time to 00:00:00
- indexOf returning -1 despite object being in the a
- How can my Google Apps Script be run by others the
- How to stop execution of Google Apps Script?
- Profiling the Performance of a Google App Script
- String starts with in Google Script
Anton Soradoi's answer seems OK but consider using Cache Service instead of storing data into a temporary sheet.
Also note that as of April 2014 the limitation of script runtime is 6 minutes.
One thing you could do (this of course depends on what you are trying to accomplish) is:
This is not a one-size-fit-all solution, if you post your code people would be able to better assist you.
Here is a simplified code excerpt from a script that I use every day:
NOTE#1: The variable
REASONABLE_TIME_TO_WAIT
should be should be large enough for the new trigger to fire. (I set it to 5 minutes but I think it could be less than that).NOTE#2:
doSomeWork()
must be a function that executes relatively quick( I would say less than 1 minute ).NOTE#3 : Google has deprecated
Script Properties
, and introducedProperties Service
in its stead. The function has been modified accordingly.If you are using G Suite Business or Enterprise edition. You can register early access for App Maker after App maker enabled your script run runtime will increase run time from 6 minutes to 30 minutes :)
More details about app maker Click here
I have used the ScriptDB to save my place while processing a large amount of information in a loop. The script can/does exceed the 5 minute limit. By updating the ScriptDb during each run, the script can read the state from the db and pick up where it left off until all processing is complete. Give this strategy a try and I think you'll be pleased with the results.
Also, try to minimize the amount of calls to google services. For example, if you want to change a range of cells in the spreadsheets, don't read each one, mutate it and store it back. Instead read the whole range (using Range.getValues()) into memory, mutate it and store all of it at once (using Range.setValues()).
This should save you a lot of execution time.