Stay organized with collections Save and categorize content based on your preferences.
ClockTriggerBuilderA builder for clock triggers.
Detailed documentationafter(durationMilliseconds)
Specifies the minimum duration (in milliseconds) after the current time that the trigger runs. The actual duration might vary, but won't be less than your specified minimum.
// Creates a trigger that runs 10 minutes later ScriptApp.newTrigger('myFunction').timeBased().after(10 * 60 * 1000).create();Parameters Name Type Description
durationMilliseconds
Integer
The minimum duration (in milliseconds) after the current time when the trigger should run. Return
ClockTriggerBuilder
— The builder, for chaining.
at(date)
Specifies when the trigger runs.
// Creates a trigger for December 1, 2012 const triggerDay = new Date(2012, 11, 1); ScriptApp.newTrigger('myFunction').timeBased().at(triggerDay).create();Parameters Name Type Description
date
Date
A Date object representing when the trigger should run. Return
ClockTriggerBuilder
— The builder, for chaining.
atDate(year, month, day)
Specifies that the trigger fires on the given date, by default near midnight (+/- 15 minutes).
// Schedules for January 1st, 2013 ScriptApp.newTrigger('myFunction').timeBased().atDate(2013, 1, 1).create();Parameters Name Type Description
year
Integer
The calendar year to schedule the trigger. month
Integer
The calendar month to schedule the trigger (should be a number between 1 and 12, inclusive). day
Integer
The calendar day to schedule the trigger (should be a number between 1 and 31, inclusive). Return
ClockTriggerBuilder
— The builder, for chaining.
atHour(hour)
Specifies the hour the trigger at which the trigger runs.
// Runs between 5am-6am in the timezone of the script ScriptApp.newTrigger('myFunction') .timeBased() .atHour(5) .everyDays( 1) // Frequency is required if you are using atHour() or nearMinute() .create();Parameters Name Type Description
hour
Integer
The hour at which to fire. Return
ClockTriggerBuilder
— The builder, for chaining.
create()
Creates the trigger.
ReturnTrigger
— The newly created, scheduled trigger.
everyDays(n)
Specifies to run the trigger every n
days.
ScriptApp.newTrigger('myFunction').timeBased().everyDays(3).create();Parameters Name Type Description
n
Integer
The number of days between executions. Return
ClockTriggerBuilder
— The builder, for chaining.
everyHours(n)
Specifies to run the trigger every n
hours.
ScriptApp.newTrigger('myFunction').timeBased().everyHours(12).create();Parameters Name Type Description
n
Integer
The number of hours between executions. Return
ClockTriggerBuilder
— The builder, for chaining.
everyMinutes(n)
Specifies to run the trigger every n
minutes. n
must be 1, 5, 10, 15 or 30.
ScriptApp.newTrigger('myFunction').timeBased().everyMinutes(10).create();Parameters Name Type Description
n
Integer
The number of minutes between executions. Return
ClockTriggerBuilder
— The builder, for chaining.
everyWeeks(n)
Specifies to run the trigger every n
weeks.
ScriptApp.newTrigger('myFunction') .timeBased() .everyWeeks(2) .onWeekDay(ScriptApp.WeekDay.FRIDAY) .create();Parameters Name Type Description
n
Integer
The number of weeks between executions. Return
ClockTriggerBuilder
— The builder, for chaining.
inTimezone(timezone)
Specifies the timezone for the specified dates/time when the trigger runs. By default, the timezone is that of the script.
The list of valid timezone strings corresponds with the valid timezone strings listed by Joda.org. An invalid timezone string causes the script to throw an error.
// Schedule the trigger to execute at noon every day in the US/Pacific time zone ScriptApp.newTrigger('myFunction') .timeBased() .atHour(12) .everyDays(1) .inTimezone('America/Los_Angeles') .create();Parameters Name Type Description
timezone
String
The timezone with which to treat time information in the event. Return
ClockTriggerBuilder
— This ClockTriggerBuilder
, for chaining.
nearMinute(minute)
Specifies the minute at which the trigger runs (plus or minus 15 minutes). If nearMinute()
is not called, a random minute value is used.
// Runs at approximately 5:30am in the timezone of the script ScriptApp.newTrigger('myFunction') .timeBased() .atHour(5) .nearMinute(30) .everyDays( 1) // Frequency is required if you are using atHour() or nearMinute() .create();Parameters Name Type Description
minute
Integer
The minute at which to fire. Return
ClockTriggerBuilder
— The builder, for chaining.
onMonthDay(day)
Specifies the date in the month that the trigger runs.
// Schedules for the first of every month ScriptApp.newTrigger('myFunction').timeBased().onMonthDay(1).create();Parameters Name Type Description
day
Integer
The day of the month the trigger should be scheduled for. Return
ClockTriggerBuilder
— The builder, for chaining.
onWeekDay(day)
Specifies the day of the week that the trigger runs.
ScriptApp.newTrigger('myFunction') .timeBased() .onWeekDay(ScriptApp.WeekDay.FRIDAY) .create();Parameters Name Type Description
day
Weekday
The day of the week to fire. Return
ClockTriggerBuilder
— The builder, for chaining.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["The `ClockTriggerBuilder` helps to create custom time-driven triggers for your Apps Script functions."],["Triggers can be set to run at specific times, dates, or intervals (every minute, hour, day, week)."],["You can customize the trigger's frequency, time zone, and specific execution time using the builder's methods."],["The `create()` method finalizes the configuration and creates the actual trigger."],["Use the ClockTriggerBuilder in combination with `ScriptApp.newTrigger(\"myFunction\").timeBased()` to create a schedule for your function."]]],["The `ClockTriggerBuilder` allows users to schedule triggers with specific timing. You can set triggers to run `after` a duration, `at` a specific date/time, or `atDate` for a particular year, month, and day. Triggers can also be configured to repeat `everyDays`, `everyHours`, `everyMinutes`, or `everyWeeks`. You can further specify triggers by `atHour`, `nearMinute`, `onMonthDay`, `onWeekDay`, and define the `inTimezone`. Finally, the `create` method builds and schedules the defined trigger.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4