bumbleshoot
bumbleshoot

Reputation: 1160

Cannot create hourly trigger near minute 16 in Google Apps Script

I ran the following function in Google Apps Script:

function createTrigger() {
  ScriptApp.newTrigger('myFunction')
    .timeBased()
    .nearMinute(16)
    .everyHours(1)
    .create();
}

and a trigger was created which runs every hour at minute 52. According to the documentation, .nearMinute(16) should create a trigger that runs between minute 1 and minute 31. Am I doing something wrong?

Upvotes: 0

Views: 687

Answers (1)

ziganotschka
ziganotschka

Reputation: 26836

nearMinute(minute) does not refer to the minute at which the trigger is created, but the one close to which it will run every hour

  • As for the creation time, in your case the trigger gets created directly when you run the function createTrigger().

  • However, for a clock trigger the creation time is not important and does not affect at what time the trigger will run.

  • Your function builds a trigger that will run each hour near minute 16 - no matter at what time the trigger is created.

Upvotes: 0

Related Questions