Class ClockTriggerBuilder

ClockTriggerBuilder

クロックトリガーのビルダー。

Methods

メソッド戻り値の型概要
after(durationMilliseconds)ClockTriggerBuilder現在のトリガー実行時刻以降の最小期間(ミリ秒単位)を指定します。
at(date)ClockTriggerBuilderトリガーの実行タイミングを指定します。
atDate(year, month, day)ClockTriggerBuilder指定した日付にトリガーを起動するように指定します。デフォルトでは深夜 0 時前後(+/- 15 分)にトリガーが発動します。
atHour(hour)ClockTriggerBuilderトリガーを実行する時間を指定します。
create()Triggerトリガーを作成する。
everyDays(n)ClockTriggerBuilderトリガーを n 日ごとに実行するよう指定します。
everyHours(n)ClockTriggerBuilderトリガーを n 時間ごとに実行するよう指定します。
everyMinutes(n)ClockTriggerBuilderトリガーを n 分ごとに実行するよう指定します。
everyWeeks(n)ClockTriggerBuilderトリガーを n 週間ごとに実行するよう指定します。
inTimezone(timezone)ClockTriggerBuilderトリガーの実行時に指定した日時のタイムゾーンを指定します。
nearMinute(minute)ClockTriggerBuilderトリガーを実行する分を指定します(プラスまたはマイナス 15 分)。
onMonthDay(day)ClockTriggerBuilderトリガーを実行する月の日付を指定します。
onWeekDay(day)ClockTriggerBuilderトリガーを実行する曜日を指定します。

詳細なドキュメント

after(durationMilliseconds)

現在のトリガー実行時刻以降の最小期間(ミリ秒単位)を指定します。実際の期間は異なる場合がありますが、指定した最短期間より短くはなりません。

// Creates a trigger that runs 10 minutes later
ScriptApp.newTrigger("myFunction")
  .timeBased()
  .after(10 * 60 * 1000)
  .create();

パラメータ

名前説明
durationMillisecondsInteger現在時刻からトリガーを実行する最小継続時間(ミリ秒単位)。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


at(date)

トリガーの実行タイミングを指定します。

// Creates a trigger for December 1, 2012
var triggerDay = new Date(2012, 11, 1);
ScriptApp.newTrigger("myFunction")
  .timeBased()
  .at(triggerDay)
  .create();

パラメータ

名前説明
dateDateトリガーの実行タイミングを表す Date オブジェクト。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


atDate(year, month, day)

指定した日付にトリガーを起動するように指定します。デフォルトでは深夜 0 時前後(前後 15 分前)にトリガーが発動します。

// Schedules for January 1st, 2013
ScriptApp.newTrigger("myFunction")
  .timeBased()
  .atDate(2013, 1, 1)
  .create();

パラメータ

名前説明
yearIntegerトリガーをスケジュールする年。
monthIntegerトリガーをスケジュールする月(1 ~ 12 の範囲内の数値)。
dayIntegerトリガーをスケジュールするカレンダーの日付(1 ~ 31 の数値で指定する必要があります)。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


atHour(hour)

トリガーを実行する時間を指定します。

// 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();

パラメータ

名前説明
hourInteger配信する時間です。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


create()

トリガーを作成する。

リターン

Trigger - 新しく作成されたスケジュール トリガー。


everyDays(n)

トリガーを n 日ごとに実行するよう指定します。

ScriptApp.newTrigger("myFunction")
  .timeBased()
  .everyDays(3)
  .create();

パラメータ

名前説明
nInteger実行の間隔(日数)。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


everyHours(n)

トリガーを n 時間ごとに実行するよう指定します。

ScriptApp.newTrigger("myFunction")
  .timeBased()
  .everyHours(12)
  .create();

パラメータ

名前説明
nInteger実行の間隔(時間数)。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


everyMinutes(n)

トリガーを n 分ごとに実行するよう指定します。n は 1、5、10、15、30 のいずれかにする必要があります。

ScriptApp.newTrigger("myFunction")
  .timeBased()
  .everyMinutes(10)
  .create();

パラメータ

名前説明
nInteger実行の間隔(分)。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


everyWeeks(n)

トリガーを n 週間ごとに実行するよう指定します。

ScriptApp.newTrigger("myFunction")
  .timeBased()
  .everyWeeks(2)
  .onWeekDay(ScriptApp.WeekDay.FRIDAY)
  .create();

パラメータ

名前説明
nInteger実行の間隔(週数)。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


inTimezone(timezone)

トリガーの実行時に指定した日時のタイムゾーンを指定します。デフォルトでは、タイムゾーンはスクリプトのタイムゾーンです。

有効なタイムゾーン文字列のリストは、Joda.org に記載されている有効なタイムゾーン文字列に対応しています。タイムゾーン文字列が無効な場合、スクリプトはエラーをスローします。

// 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();

パラメータ

名前説明
timezoneStringイベントの時刻情報を扱うタイムゾーン。

リターン

ClockTriggerBuilder - この ClockTriggerBuilder(チェーン用)。


nearMinute(minute)

トリガーを実行する分を指定します(プラスまたはマイナス 15 分)。nearMinute() が呼び出されない場合、ランダムな「分」の値が使用されます。

// 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();

パラメータ

名前説明
minuteInteger発動する分。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


onMonthDay(day)

トリガーを実行する月の日付を指定します。

// Schedules for the first of every month
ScriptApp.newTrigger("myFunction")
  .timeBased()
  .onMonthDay(1)
  .create();

パラメータ

名前説明
dayIntegerトリガーをスケジュールする日。

リターン

ClockTriggerBuilder - チェーン用のビルダー。


onWeekDay(day)

トリガーを実行する曜日を指定します。

ScriptApp.newTrigger("myFunction")
  .timeBased()
  .onWeekDay(ScriptApp.WeekDay.FRIDAY)
  .create();

パラメータ

名前説明
dayWeekday配信する曜日。

リターン

ClockTriggerBuilder - チェーン用のビルダー。