How to set a custom frequency trigger on google apps script

前端 未结 2 1394
情歌与酒
情歌与酒 2020-12-22 01:22

I\'m a new user for Google apps script, I meet a question recently. In Google apps script, I want to set a trigger to run the app on 9:00AM every day. But I can only set a t

2条回答
  •  Happy的楠姐
    2020-12-22 01:43

    As far as I know, the "Add a trigger" feature will only let you set triggers within this one hour range.

    You can, however, set a narrower time range if you create your trigger programmatically (using the ClockTriggerBuilder class). It'll still have a thirty minute range, though: the app run will run at 9am plus or minus 15 minutes. Is that close enough for you or do you need it to run at 9am sharp?

    It would go like this:

    ScriptApp.newTrigger('YourFunction')
      .timeBased()
      .everyDays(1)
      .atHour(9)
      .create();
    

    Here you can find more information

提交回复
热议问题