0

I am running a long app script which times out after 6 mins. What is the best way to restart the script from the same place? Like some trigger?

Patrice
  • 4,641
  • 9
  • 33
  • 43
  • If your one script is taking too long to execute it would probably simplest all around to just break it into smaller parts that won't take 6 minutes. – Dan Oswalt Apr 02 '15 at 23:32
  • and/or examine the transcript to see if there are obvious time-sucking service calls or slow methods that can be changed to be faster – Dan Oswalt Apr 02 '15 at 23:33
  • I cannot do that because I am running app script to run large queries on GBQ. My understanding is that breaking the script into smaller parts means pressing the run multiple times? – RAGHAV RASTOGI Apr 03 '15 at 01:23
  • You can run it multiple times with triggers set to go off every 10 minutes for each successive part, for example. I don't know if that's feasible. Perhaps add a google bigquery tag to this question. The problem with starting where you left off is being able to log your progress every step of the way, you just never can tell when or where Google scripts are going to time out. – Dan Oswalt Apr 03 '15 at 05:30
  • There is no way to automatically start where it was stopped. You need to keep a state and some sort of queue and use time based triggers. – Zig Mandel Apr 04 '15 at 15:48

2 Answers2

0

You might be interested in a tool written by Bruce Mcpherson for massively parallel processing in Google Apps Script.

http://ramblings.mcpher.com/Home/excelquirks/htmlservice/parallel

http://ramblings.mcpher.com/Home/excelquirks/htmlservice/parallel/implement

Spencer Easton
  • 5,642
  • 1
  • 16
  • 25
0

Take a look at the Continuous Batch Library which is a straight forward way to get your script to run every 7 mins. It returns a key so you can keep track of the progress of each batch. These batches would run is series - once after each other, rather than the parallel processing Bruce Mcpherson's script provides.

Andrew Roberts
  • 2,720
  • 1
  • 14
  • 26