impossible to terminate function (>500 000s of execution) - google-apps-script

I've built automation on apps script. I have a trigger that runs every minute and the automation was working well for one week. Suddenly, I had an execution that wasn't stopping and it's still impossible to terminate it. (see picture) I have an error message when I'm on the dashboard and try to kill it. The automation uses API technology and Jdbc connections
Do you have any clue how to terminate it? It's burning all my daily quota of execution time.
Thanks!

Go to https://script.google.com
Click on My Executions
Find your script
Right click over your script and select Terminate

Related

How do I delete the script execution history in google scripts?

Simple question, but... I wrote my first script and it runs perfect... but, how do I manually delete the script execution history in google scripts?
Wait 7 days.
From https://developers.google.com/apps-script/guides/logging
The built-in Apps Script execution log. This log is lightweight and streams in real time, but persists only for a short time.
The execution page shows this:
Showing n executions over last 7 days

How do I restart a failed Google Apps Script Trigger?

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.

Change queue time of Google spreadsheet app script trigger

When I create a daily time-based trigger for the Google app script associated with my Google spreadsheet, I am prompted to select an execution time that is within an hour-long window, and it appears that a cron wrapper randomly assigns an exact execution time within that hour-long interval.
Because my application's specific use case has several data dependencies which may not be completed early in the hour, I was forced to divide my application into several stages, with separate triggers each delayed by an hour, to insure that the required data would be available.
For example, the trigger time that was initially assigned for my script was 6:03AM, but the data which usually arrived at 5:57AM, occasionally did not arrive until 6:10AM and the script had nothing to process for that day. As a blunt force solution, I deleted the 6-7AM trigger and re-created it to execute in the 7-8AM time slot to insure the required data was available. This required that the second stage of the script had to be moved to 8-9AM, resulting in script results which could be delayed by as much as 2-3 hours.
To improve this situation, I am contemplating integrating the two script processing stages and creating a more accurate script execution trigger time, say 6:30AM to be safe. Does anyone know if:
Is it possible, other than by observing daily processing, to discover the exact trigger execution time that has been assigned, and
If randomly assigned, can script triggers be created and deleted until an acceptably precise execution time is obtained?
Thanks in advance for any guidance provided.
If accuracy is paramount, you can forgo using apps script triggers altogether and leverage a 3rd party tool instead.
I'd recommend using cron-job.org. This service can create cron jobs that make POST requests to a url endpoint you specify, and you can schedule times accurate to a minute. To use it with Apps Script implement a doPost() to handle post requests and deploy your script as a Web APP. You then create a cron job using the service and pass it the web app's URL as an endpoint.
The cron job will fire at the scheduled time and you can perform any requisite operations inside the doPost() in response to the incoming POST request.
Thank you to random parts and Dimu Designs for the guidance. Based upon experimentation, here are the answers to my questions:
Is it possible, other than by observing daily processing, to discover the exact trigger execution time that has been assigned? Answer: No way except by observing the random trigger time assigned within the requested hour window.
If randomly assigned, can script triggers be created and deleted until an acceptably precise execution time is obtained? Answer: Yes. I adjusted my script's assigned execution time by observing a trigger's execution time (via email message timestamp), and deleting, recreating, and observing the randomly assigned trigger execution time until I got an acceptable minute within the requested hour window.

How comes my script fails to run while executed by a trigger but is successful when executed manually?

I'm not sure if I have encountered with a bug or is just me not fully understanding how triggers work, probably the second one :D.
I have a google apps script that collects information through a series of requests to our CRM's API and puts it on a Google Docs Spreadsheet, the script takes a while to run, however, it runs successfully (I run it manually every morning, takes about 3 minutes). But when I try to automate that task, I get an error message saying my script exceeded its execution time limit.
I tried setting up my triggers manually, creating them within the script, breaking down my script reducing the number of API requests (taking less then a minute to execute) and execute it several times so I get the whole information. Every single time I get the same error message.
Am I missing something here? Any help will be much appreciated!
Edit: The mail I received has this error message: "Exceeded maximum execution time".
Edit2: I was able to fix this (party). I came across the answer for this question Exceeded maximum execution time in Google Apps Script and worked like a charm.
There are some limits to Google Apps Scripts that you must keep in mind: see Quotas.
It is possible that you are exceeding your total runtime for Triggers. There is also the shorter individual execution time limits on Triggers. I think I remember reading somewhere that Triggers have a lower total execution time limit per execution, but I can't remember where I saw it, and I can't find a source, even in Google's documentation.
This SO question is also similar...
I wouldn't say it's a bug, however as my own painfully experience, I can tell it's not the same running the script manually than through a time-driven trigger.
Sometimes it's just slower, but others it fails for timeout.
I don't know your specifics (there is no code available), but I would recommend you to use a retry exponential backoff function wrapping any critical call and also check for a timeout warning (let's say at 5 minutes) within the main loop.

How long will a Google Apps Script continue to run unattended

I have written a standalone Script, which is stored in my Drive account and I have set up a trigger to run it at set intervals (several times daily, if it's relevant).
If I don't log in to my account and the Script doesn't experience any unhandled errors or exceed quotas, how long will it continue running unattended?
Indefinitely?
Once you've set up a trigger as you've described, the script will continue run indefinitely, even if there are errors or exceeded quotas. (It will launch - but may fail again or get killed immediately for exceeded quota.)
For this reason, you should ensure that you have set notifications appropriately.
In Understanding Triggers, the behaviour of time-based triggers is explained, but it does not explicitly state that triggers run indefinitely. On the other hand, it does not say that they stop running - implying that they don't. (I have triggers that have been running daily for years.)
There have been reported instances of triggers misfiring (Issue 2708, 2746, 2547), as well as a personal favourite - scripts that continue to trigger after deletion (Issue 143).