Home > Blockchain >  Check if Trigger is already running
Check if Trigger is already running

Time:09-14

I'm trying to run a script on a Google Sheet that updates the sheets after pulling data from a MySQL DB. It runs a trigger at the end, but I think it's re-starting the trigger every time it runs, resulting in multiple timeBased triggers running concurrently. I don't know Java, but is there a way to check if the trigger is already running and bypass if it is?

Like:

if (trigger_running) {continue} else {runTrigger}?

Here's the basics of the function & trigger:

function readData() {
  //open connection
  //fetch data
  //update sheet(s)
  //close connection
}


/* Schedule run/update */
 ScriptApp.newTrigger('readData')
 .timeBased()
 .everyMinutes(5)
 .create();

CodePudding user response:

Your ScriptApp.newTrigger() call is in the global space which makes it run every time any function in your script project gets executed. You should delete that bit of code or comment it out.

Then visit the enter image description here

You can also watch the triggers from here:

enter image description here

  • Related