r/GoogleAppsScript • u/VAer1 • 7d ago
Unresolved Google Apps Script trigger frequency setting
Google Apps Script trigger frequency setting: Currently, I have hourly triggers set up for 15 functions, but running all of them every hour seems excessive, even though the 90-minute daily quota is still sufficient.
I'm wondering if there's a way to schedule them to run every two hours, specifically at even-numbered hours (e.g., 8 AM, 10 AM, noon, etc.), so the schedule won't be affected by daylight saving time changes.
Alternatively, I could keep hourly triggers but limit them to between 6 PM and midnight, since there's no need for these functions to run during the rest of the day.
I mean setting only, not the script to check hour.
Edit: I follow the comment and created a master trigger. Now I have new question https://www.reddit.com/r/GoogleAppsScript/comments/1xzjvlk/how_to_call_a_function_from_another_project_when/
View all comments
1
u/No-Sheepherder7116 7d ago
Yes, but the two options in Apps Script do not do exactly the same thing, and that is the key point here.
1. Every 2 hours in the trigger settings
In the editor, go to Triggers > Add Trigger, choose Time-driven, then Hour timer. The interval list includes Every 2 hours, as well as 4, 6, 8 and 12 hours. The code equivalent is:
That will halve your runs, but it does not let you choose 8 AM, 10 AM, noon, and so on. It is interval-based: the first run happens within two hours of when you create the trigger, then roughly every two hours after that, and the exact minute is not guaranteed. So creating it at 8 AM gets you roughly even-hour runs, but it is not a promise, and it can shift around a daylight saving change.
2. Exact even hours, DST-proof: daily triggers at set hours
For exact clock times, create a daily trigger for each hour you want:
Repeat that for 10, 12, and so on. These use the script timezone in Project Settings, so they stay on wall-clock time through a daylight saving change - 8 AM stays 8 AM.
The catch is the limit: 20 triggers per user, per script. With 15 separate functions, one daily trigger per function per hour would be far over that limit in a single project - 15 functions x 4 hours is 60 triggers.
So the practical way to do what you asked, without any hour-checking code in the functions themselves, is to consolidate. Put one wrapper function in the project that just calls the 15 functions, then give that wrapper a few daily triggers, for example at 18, 20 and 22 if you want the 6 PM to midnight window. Add 0 to the list if you also want a run at midnight:
Run setupEvenHourSchedule() once. The delete step at the top just stops you creating duplicate triggers if you run the setup again. Also delete the old hourly triggers for those 15 functions, or they will keep running every hour alongside the new schedule.
On your last question: yes, they have to be in the same project for this to work directly. A trigger can only call a function in its own Apps Script project. If your functions are spread across projects, each project needs its own triggers, and each project gets its own 20-trigger limit.
So in short: if roughly every two hours is good enough, use Every 2 hours in the trigger settings. If the exact even hours matter and you want them DST-proof, use the wrapper plus daily atHour triggers.