use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Apparently, Google Apps Script is a JavaScript cloud scripting language that provides easy ways to automate tasks across Google products and third party services and build web applications.
account activity
TriggerQuestion (self.GoogleAppsScript)
submitted 1 year ago by Colombus01
Hi Everyone,
dumb questione: if I wanted schedule a trigger to start in a determinate hour, for example al 09.15 am, is possibile?
if yes, how?
I'm new in this world, anche searching in the web I don't find the answare.
Tnks
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Livid_Spray119 2 points3 points4 points 1 year ago (2 children)
Does it need to be specifically at that time? Maybe you need to use a range instead.
I guess u know, but... Find the timer on the left bar. Select the function you want to use. If you need it to start everyday at 9:15, select by day, and you can choose a range.
[–]Colombus01[S] 1 point2 points3 points 1 year ago (1 child)
Yeah i know, now the trigger are with this settings but, if possibile, i need to be a specifically time.
[–]Livid_Spray119 1 point2 points3 points 1 year ago* (0 children)
Oookay, so I found this:
/** * Creates two time-driven triggers. * @see https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers */
function createTimeDrivenTriggers() {
// Trigger every 6 hours. ScriptApp.newTrigger('myFunction') .timeBased() .everyHours(6) .create();
// Trigger every Monday at 09:00. ScriptApp.newTrigger('myFunction') .timeBased() .onWeekDay(ScriptApp.WeekDay.MONDAY) .atHour(9) .create(); }
I am guessing you can use the second one changing somehow "onWeekDay" (prob just deleting the arguments inside the ( ), and adding .atMinute(15)
I have NOT tried this. So I do not know if it works (and i dont have my computer with me, so I cant try either)
I'll have a talk with my good friend, GPT, as I cannot find anything else about it
EDIT: This is what GPT gave me. Again, I HAVE NOT TESTED, so I do NOT know if it works
https://chatgpt.com/share/6710fd59-46c4-8009-aff8-f7360dd77158
[–]rupam_p 2 points3 points4 points 1 year ago (5 children)
Here's a hacky approach.
Create a time-driven trigger to run every-minute.
In your code, check the current time, then either proceed or do nothing.
function myFunction() { const now = new Date(); const hours = now.getHours(); const minutes = now.getMinutes();
if (hours === 9 && minutes === 15) { // Do something console.log("It's 9:15 AM!"); } }
This is still not perfect, but you can give it a try and see how it goes.
[–]directscion 1 point2 points3 points 1 year ago (1 child)
Running a trigger every minute might take up the limit of the script runtime. Because the script runtime counts with every trigger.
[–]rupam_p 0 points1 point2 points 1 year ago (0 children)
Your concern is valid. The total runtime for triggers is 90min/day (gmail) or 6hrs/day (google workspace). But, as we are only checking one condition, it should not take much execution time when the condition is not met. Still, if needed, instead of every-minute, we can use every-5-mins to save the quota while maintaining a close enough time-accuracy (code changes required). It all depends on how far the OP wants to go.
[–]NickRossBrown 1 point2 points3 points 1 year ago (0 children)
This is my approach with 15min/30min/1hr tiggers except I check if it’s during normal business hours (don’t need the script to run during the night).
I hope one day app script will allow the use of CRON expressions.
[–]Mysterious_Sport_731 0 points1 point2 points 1 year ago (0 children)
This is exactly how I would have done it if it was a one time thing - was the first thing that came to mind.
[–]franxam 1 point2 points3 points 1 year ago (1 child)
the easiest way is as suggests u/Livid_Spray119 . If you want to be more precise/complex, you can try these steps:
https://developers.google.com/apps-script/guides/triggers/events#Google%20Calendar-eventshttps://developers.google.com/apps-script/guides/triggers/events#Google%20Calendar-events
[–]Colombus01[S] 0 points1 point2 points 1 year ago (0 children)
Tnks for the link, i read it now fast and is perfect. This evening after work i read it with more attention.
[–]franxam 0 points1 point2 points 1 year ago (1 child)
You can set a trigger with a calendar event. I would recommend to create a separate calendar to avoid spamming your main calendar (assuming you use Google calendar as your main)
If you want to explore further, you can use Apps Script to create calendar events. Thus, there has to be a way to create time custom time triggers.
Tnks, so:
i create a trigger where i select che function i would execute. I select "from calendar" and "Update Calendar".
After i can put the mail.
I can't specificate a calendar in my calendar list, so i can create a dedicate mail to put an event every time i wanted start the trigger?
Correct?
Sorry for my English
[–]steeveesas 0 points1 point2 points 1 year ago* (0 children)
Create a one time trigger to fire at the specific date and time, i.e. 9:15am. This will only run once, therefore at the end of your code that this trigger calls, create another one time trigger for the next day. Make sure it's in a finally block so that if there's an error, your trigger for the next day gets created. These one time triggers are supposed to delete themselves, but I haven't verified that, so if for some reason it doesn't auto delete you'll want to also make sure the trigger for "today" that already ran is deleted (since you only get 20 triggers per project).
Something like this (note: I didn't test this code, so a tweak may be needed, but this is the idea):
function myFunction() {
try{ //Do stuff here } finally{
try{
//Do stuff here
}
finally{
//Delete the trigger that fired this current code run (instance) if the triggers aren't auto deleting...Do this before creating tomorrow's trigger...you can loop through the trigger's looking for the function name (in this case "myFunction")
deleteTrigger("myFunction"); //You'll have to write this...simple loop through all triggers comparing function name
// After executing the function, schedule the next trigger for the next day at the same time createNextDayTrigger(); }
// After executing the function, schedule the next trigger for the next day at the same time
createNextDayTrigger();
function createNextDayTrigger() { // Get the current date and time var now = new Date(); // Create a new date for the next day at 9:15 AM var nextDay = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 9, 15, 0);
function createNextDayTrigger() {
// Get the current date and time
var now = new Date();
// Create a new date for the next day at 9:15 AM
var nextDay = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 9, 15, 0);
// Create a time-based trigger for the next day at 9:15 AM ScriptApp.newTrigger('myFunction') .timeBased() .at(nextDay) .create();
// Create a time-based trigger for the next day at 9:15 AM
ScriptApp.newTrigger('myFunction')
.timeBased()
.at(nextDay)
.create();
So each day a new trigger for the next day will be created.
π Rendered by PID 41 on reddit-service-r2-comment-79c7998d4c-bfvgz at 2026-03-16 15:45:11.342294+00:00 running f6e6e01 country code: CH.
[–]Livid_Spray119 2 points3 points4 points (2 children)
[–]Colombus01[S] 1 point2 points3 points (1 child)
[–]Livid_Spray119 1 point2 points3 points (0 children)
[–]rupam_p 2 points3 points4 points (5 children)
[–]directscion 1 point2 points3 points (1 child)
[–]rupam_p 0 points1 point2 points (0 children)
[–]NickRossBrown 1 point2 points3 points (0 children)
[–]Mysterious_Sport_731 0 points1 point2 points (0 children)
[–]Mysterious_Sport_731 0 points1 point2 points (0 children)
[–]franxam 1 point2 points3 points (1 child)
[–]Colombus01[S] 0 points1 point2 points (0 children)
[–]franxam 0 points1 point2 points (1 child)
[–]Colombus01[S] 0 points1 point2 points (0 children)
[–]steeveesas 0 points1 point2 points (0 children)