问题
I need to run a Google Apps script three times a day: at 8:00, 12:30, 17:00.
How to do this?
I have already looked at Triggers
, and more specifically Time driven
:
Hour timer, but
Every hour
,Every 2 hours
,Every 4 hours
are not adapted hereDay timer, but then
8am to 9am
is not very precise, I would prefer something more precise, and also 12:30 is not possibleSpecific time, but then
YYYY-MM-DD HH:MM
is not adapted to run it daily
From calendar
triggers does not seem adapted either.
回答1:
Use nearMinute() and atHour():
const createTrigger = ([hour, minute])=>
ScriptApp.newTrigger("myFunction")
.timeBased()
.atHour(hour)
.nearMinute(minute)
.everyDays(1)
.create();
[[8,0],[12,30],[17,0]].forEach(createTrigger)
来源:https://stackoverflow.com/questions/60773329/run-a-gmail-google-apps-script-daily-at-800-1230-1700