Time-driven triggers
A time-driven trigger (also called a clock trigger) is similar to a cron job in Unix. Time-driven triggers let scripts execute at a particular time or on a recurring interval, as frequently as every minute or as infrequently as once per month. (Note that an add-on can use a time-driven trigger once per hour at most.) The time may be slightly randomized — for example, if you create a recurring 9 a.m. trigger, Apps Script chooses a time between 9 a.m. and 10 a.m., then keeps that timing consistent from day to day so that 24 hours elapse before the trigger fires again.
Do apps script triggers respect local time zone? I'm on the east coast (EST) but when I look at my logs a time based function scheduled between 8-9, has not fired (its now 10AM)
Related
I have a lot of time-driven triggers that query my Cloud SQL server and update information in Google Sheets.
Today, I went over my daily quota and got the following error message:
Jun 9, 2020, 7:37:11 AM Error Service invoked too many times for one day: premium jdbc connection.
All of my triggers stopped firing at 7:40 am. It's now 1pm. I can manually run all of my functions, and they finish without errors. However, I've deleted and re-created triggers, and no triggers will run on my account. Do I need to wait 24 hours? Is there somewhere else I can reset triggers? Do I need to create a new Apps Script Project?
As mentioned in comments, I waited until the rolling 24-hour quota refreshed (it was less than 24 hours). The quota I was maxed out on seems to be a rolling 24-hour Usage Time, so it doesn't reset to zero, it just gives you additional Usage Time as old usage rolls off.
Helpful suggestion in comments - Create a master script to add/remove all triggers, calling the other scripts as libraries. This allows you to quickly Delete all triggers, wait for the quota to reset/refresh, and add triggers back slowly or all at once. Otherwise you may have Triggers that continually fire as soon as your quota has room, thereby maxing out your quota again.
If I have hundreds of triggers set to work on a specific day of the week within the same hour time frame (lets say Monday between 8 am to 9 am) - will they be executed in the way that will burden the least on the server?
If not - according to which consideration the execution time will be determine?
Is there a limtation of amount of triggers in an hour/day? What is it? (in Quotas for Google Services I found only a Triggers total runtime).
Thanks!
I have a simple onEdit script that can run longer than 30 seconds, depending on what I am doing on my spreadsheet and in some cases, I need this to happen.
I understand, if I do not use an installable trigger in this case, that the simple onedit script will time out. So I now have a simple onEdit trigger and installable onEdit trigger that can run at the same time.
But here is my problem. I mentioned that I need my script to run longer than 30 seconds sometimes. But if I use an installable trigger, in conjunction with the simple trigger, the onEdit function will begin to cause the changes that do not require 30 seconds of run time to fire twice and I don’t want this to happen.
Incidentally, if I do not use an installable trigger and only use the simple trigger, the changes that do not require 30 seconds of run time fire once and do as I need. But then the changes that require 30 seconds of run time times out, incompleting the tasks that I need done.
So how do I get the installable trigger to run the changes needed under 30 seconds once, while still giving me the ability to run changes longer than 30 seconds when needed?
You are right about that the simple triggers cannot run for longer than 30 seconds, while the installable ones do.
So, why do you not user ONLY the installable trigger without the
simple one. You can bind it to any desired function, it doesn't need
to be called onEdit().
I'm running some scripts on a daily bases in a spreadsheet, at this point I have two scripts running and both have to be triggered at same time (7am to 8am) but I need the script GeraPDF comes first. How do I define the priority of triggers when the events are the same?
You can't put a priority for two trigger when they've got the same day timer, cause Apps script is choosing the moment between 7am and 8am where your script gonna run (see here).
A time-driven trigger (also called a clock trigger) is similar to a
cron job in Unix. Time-driven triggers let scripts execute at a
particular time or on a recurring interval, as frequently as every
minute or as infrequently as once per month. (Note that an add-on can
use a time-driven trigger once per hour at most.) The time may be
slightly randomized — for example, if you create a recurring 9 a.m.
trigger, Apps Script chooses a time between 9 a.m. and 10 a.m., then
keeps that timing consistent from day to day so that 24 hours elapse
before the trigger fires again.
If you want to put a priority, you should put the day timer one hour early.
I've created a time driven trigger that would run the main function of my Google-apps-script. every 5 minutes (Gmail)
It's working fine, but I received the "Summary of failures" with the error message " Service using too much computer time for one day " 7 times.
So my question is, I'm I allowed to set the time driven trigger to run my script every 5 minutes ?
As mentioned in the documentation there is a maximum of 1 hour computing time for normal gmail account.
See reference here.