F
F
felior2022-02-08 20:23:34
Google Apps Script
felior, 2022-02-08 20:23:34

How to automatically execute a script every 5 minutes on Apps Script?

I need the script to be executed every 5 minutes automatically without a trigger (the trigger doesn't work for some reason). It may be possible to write code that will run the script every 5 minutes directly into the script.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor L, 2022-02-08
@felior

Hello, triggers can be created in two ways either manually
or programmatically

function myFunction() {
  Logger.log('1')
}

function createTimeDrivenTriggers() {
  ScriptApp.newTrigger('myFunction')
        .timeBased()
        .everyMinutes(1)
        .create();
}

6202b62c49f96736861078.png
One problem is that they have limitations. The total duration of the functions fired by the trigger cannot exceed one hour per day: this is one of the limits of the Apps Scripts system. If you call every 5 minutes, you get 288 runs per day, i.e. 12 seconds each (average). I assume that your script does not keep within this time. It is necessary either to optimize, or to launch not so often.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question