1
votes

I have a google apps script that is linked to a google sheets document. I want to run the script at the top of each hour, ie, exactly 1:00:00 pm, 2:00:00 pm, 3:00:00 pm etc.

I have set up hourly triggers from within the "Manage Project's Triggers" settings. However this will choose a random time during the hour to run the script. For example, it may run at 1:15pm or 1:56pm. It still runs once an hour, but I need it right when the hour changes.

Is it possible to set up a trigger from within the script's code such that it will run as I want, rather than a random time during each hour?

Thanks in advance!

1
create a minute trigger and exit when it's not near the hour?TheMaster

1 Answers

2
votes

Yes. Try the nearMinute option from the ClockTriggerBuilder method as documented here.

nearMinute

While it still wouldn't be 'exact', as indicated, it should be plus or minus 15 minutes.

Hope this helps!