I am trying to build a script that should run every Tuesday, Wednesday, and Thursday between 11 am to 2 pm and after every 10 minutes.
For e.g. If today is Tuesday..
You can also consider having a single trigger that runs every 10 minutes and, inside the trigger function, you can check the time and weekday. The code is executed only if all conditions are met else it returns without doing anything.
function startCustomTrigger()
{
ScriptApp.newTrigger('StartProcess').timeBased().everyMinutes(10).create();
}
function StartProcess() {
var date = new Date();
var day = date.getDay();
var hrs = date.getHours();
if ((day >= 2) && (day <= 4) && (hrs >= 11) && (hrs <= 14)) {
// Add your code here
}
}
You are going to need to set up lots of triggers to do this.
So, you need seven triggers. Three to run on that specific day, that will then create a trigger to run every 10 minutes starting at 10am. One trigger that will start at 10am and keep running indefinitely (until you shut it off). And three triggers to stop the trigger that is running every 10 minutes.
The triggers that will run on a specific day, should be set up manually. So, 6 of the triggers will be set up manually. The trigger that runs every 10 minutes needs to be created and deleted from code.
The six triggers that are a "Week timer", to run on a specific day, only need to run once to create the trigger that will run every 10 minutes. I'd run them an hour earlier than you want the 10 minute triggers to run, just to make sure they are set to go.