Updating Cloud Scheduler Job Triggers Job Run - google-apis-explorer

Updating an existing job in the GCP Console for Google Cloud Scheduler intermittently results in the job running immediately when the update is saved.
The job type is a GET request to App Engine HTTP. Editing the URL field in the GCP console and saving the job triggers an immediate job run about 50% of the time in my experience of about 10 edits over the last two weeks. The "Frequency" field defining the cron expression has not been edited in my scenario.
I expect the job to only be triggered at the time specified by the "Frequency" field or if the "Run Now" option is invoked. Editing the job resulting in an immediate execution of the job seems like a bug to me. I don't see any information about the expected behavior of a job being edited in the docs.
Note the "Frequency" and "Last run" columns in this screenshot:

Related

Faulty Installed Clock Triggers on an Add-On

I designed a rather simple Add-On to enable my local team to more easily automate newsletters and target updates to Slack.
The Add-On works well, aside from two issues:
Schedule a send functionality.
I'm using the ScriptApp's newTrigger() function to allow users to schedule automatic sends.
While it seemed to have worked in original tests, the triggers are now triggering at the wrong time (a trigger that should run daily from 11-12AM has been running at 5PM - Another that should run at 6PM has been running at 12AM - I've checked and the timezones appear to be correct GMT+2 for Paris)
GetActive() returning the wrong sheet
This is a minor problem as I've only noticed it twice, but when running a script with getActive() from the correct sheet, it accidentally ran the script using another spreadsheet.
I remain at your disposal should you need any more information, IDs or the likes.
Thank you for any help and have a fantastic day

How to get a notification if Google Script's "My Executions" shows that a script hasn't run in specified time

I have a Google Script running every 5 minutes. It works except randomly there are sudden crashes and the script/trigger won't survive that. So, for many different reasons, the script stops running after some weeks of continuing runtime. At this point, I would need a notification.
How can I get a notification if a function (script) hasn't run in say 2 hours? Doesn't matter what the technique/notification is, but probably email would be great for the notification. I don't think the solution can be in the script code itself, because the script randomly (every few weeks) crashes at Google's side and there's nothing I can do about that.
Google Apps Script installable triggers automatically set an email notification. You could edit when it should be sent (i.e. send immediately) and you could add more notifications. NOTE: This can only be done manually.
The above will work for "normal" failures but it there is a service outage or other platforms failures the notification might not be sent.
One option is to log the executions somewhere then set a second trigger to check that the first trigger ran every time that it should do it as expected. NOTE: The failure that prevented that the first trigger run might also prevent that his second trigger run i.e. a service outage so you might want to set other monitoring measures accordingly the the severity/priority of this failure and your project budget.

Your script, Drive Migrator, has recently failed to finish successfully

I have this email from google.
Your script, Drive Migrator, has recently failed to finish successfully. A summary of the failure(s) is shown below. To configure the triggers for this script, or change your setting for receiving future failure notifications, click here.
There are about 200 messages of the format:
Start 1/1/19 4:53 PM
Function processFilesAndFolders
Error Message Authorization is required to perform that action.
Trigger time-based
End 1/1/19 4:53 PM
When i click there i fund there is an empty trigger and no further information.
Project -
Last run -
Deployment -
Event Time-based
Function -
Error rate -
Its very strange given nobody was on the system at this time, and I cannot see any details about the trigger.
How do I see what is happening here? Is someone on my system, trying to move my files around? How is is possible to have a trigger that is void of information like this? It looks somewhat hacky. Can I centrally disable this "drive migrator"?
I found an old question about this: Drive Migrator Fail Message
But, perhaps it does not have enough information to get a proper answer.
I also contacted google support directly, but they said that asking here is the only way to get technical support on this service. I understand this is not the best "stackoverflow type question", but I'm at a loss on where to get further information about this.
The failure notifications likely occur when a Google Script is deleted from your Drive without de-authorization or when the permissions get revoked for some reason.
Go here and you'll find a list of all triggers running under your Google account. Delete the one associated with your Failure emails.
This guide explains how you can unsubscribe from the failure emails and also properly de-authorize the associated script.

How to enable Execution Transcript when this script runs?

I am using a script which is found here: https://moz.com/ugc/updated-tool-seomoz-api-data-for-google-docs
I would like to trigger this to run once an hour (as a test, later once a month); to facilitate this I set up a time driven trigger in the script editor UI.
I need to test that the trigger is actually working. The issue is that I do not expect any of the data to change when the script runs (might change once a month max)...
So I looked to the script editor and found View > Execution Transcript. Perfect!
Except that I get this message:
No execution transcripts found. Please run your script and try again.
This doesn't seem to be consistent with the expected behaviour after reading the Google Apps Script documentation page, which says:
Every time you run a script, Google Apps Script records an execution
transcript, which is a record of each call to a Google Apps Script
service that is made while the script runs.
(Nothing in the logs either by the ways, though maybe this is something that needs to be turned on by the script itself; not sure).
So how can I test to see that my time driven trigger works, and that the script is being run each hour?
Final note: The script is executed by calling a function in the spreadsheet, as explained in the link at the top of the question.
If you have not yet run it manually, there may be an issue with it being given the proper permissions. Your first step would be to run the code manually using the play button. Once you know that the code itself will run successfully and has the right permissions, you can move to triggering it automatically.
Your next step is to shorten your trigger time so that it executes more frequently giving you more instances to check the function. Depending on the structure of your code, you can add Logger.log() calls at different steps to make sure that all portions are being called that need to be. You can then check you logs instead of the execution transcript as well.
These Logger.log() calls could include the time at which is was called to be able to verify that it was at the time/ frequency you need.
Ok, I don't know how great this answer is... but:
For me (as per my comment to MasterCrander), running the script by means of using the function inside the spreadsheet didn't actually affect the execution transcript, but when it ran via the time driven trigger it made it into the transcript.
Problem solved.

How much time script waiting response from server? [duplicate]

This question already exists:
Exceeded maximum execution time in Google Apps Script [duplicate]
Closed 7 years ago.
My Google script, which I'm runnig from script.google.com invokes a PHP script on a remote server. This PHP script works for a few minutes, maybe more.
How much time can the Google script wait for a response from server?
Check this advice from Google.
We do not increase script execution times on a per-domain basis. There are ways for you to accomplish your use-case without any increases, however. Instead of trying to do everything in one script's execution time, use a sequence of script executions (using triggers) to process batches of the overall job. You can use ScriptDB or another persistent datastore to keep track of the documents processed, and each subsequent triggered execution can read from this and pick up processing where the previous execution left off.
Better than "waiting" for the response, is making the PHP call a new function on GAS (sorta like a callback), to do this publish your GAS with the options "As me" and "Anyone, even anonymous". Then you can call the /exec link with Get/Post parameters and continue executing the function.
This is ofcourse if your editor on the PHP page.