Two trigger at same time - google-apps-script

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.

Related

Cloud Scheduler with multiple cron schedules?

I have a Scheduler Job within Cloud Scheduler running to call a Cloud Function. Working as expected however I need to create multiple cron schedules for the same job, is this possible without recreating from scratch each one? There doesn't seem to be a Copy function.
Use Case:
Schedule 1 - Every 15 minutes Monday - Thursday
Schedule 2 - Every 15 minutes Friday SoD till Friday 22:00PM
Schedule 3 - Every 15 minutes Sunday 22:00PM till Sunday EoD
How can I achieve this, or do I just need to recreate all the schedules from scratch?
Posting this as a Community Wiki as it's based on #GuillaumeBlaquiere and #Al-dann comments.
At this point you going to need to recreate all of those schedules from scratch, however, you can automate the creation of new Jobs with a script, either with gcloud or terraform. This will make duplication, creation and deletion of Jobs easier and quicker as well as allow you to version it.

Time based triggers in google apps script - executions and limitations

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!

How Do I Get My Installable Trigger to Run Once and Not Twice?

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().

When do Apps script time based triggers fire

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)

I'm I allowed to set the time driven trigger to run every 5 min?

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.