Schedules a CRON request to execute once at an exact date in the future.
The generated request appears as any other request, but uses HTTP
method CRON to distinguish itself from external HTTP
requests. It is not possible to generate a CRON request in any way
other than by scheduling one.
To prevent abuse, only about 2000 CRON requests can be executed
by an app in any given minute. (This limit is lower for requests
that are very expensive, such as those that call
wget() and perform other high-cost operations.)
Requsts beyond this limit are rescheduled for the next minute but
ultimately canceled if the reschedule queue grows too large.
| Date | date | The date the request should trigger. |
| string | path | The path to be specified by the HTTP CRON request. Maximum length of 100 characters. |
| object | params? | Optional parameters to be given with the HTTP CRON request. Maximum of 256 bytes of data; use storage if you need more. |
| boolean | published? | Whether the request should be sent to the published version of the app, or the most recent preview version. By default only requests scheduled in published mode go to the published version of the app. |
| boolean | mailOnError? | Whether to email this app's owner if the cron request fails or is canceled; defaults to false. |
| string | A unique identifier for this cron task. |
result = schedule(new Date("Jan 12, 2008"), "/dosomething");
function cron_dosomething() {
sendEmail("you@example.com", "A scheduled message.", "Greetings!");
}
Schedules a CRON request to execute every period minutes,
starting at date.
The generated request appears as any other request, but uses
HTTP method CRON to distinguish itself from other external HTTP
requests. It is not possible to generate a CRON request in any way
other than by scheduling one.
A CRON request cannot schedule a repeating CRON request.
| Date | date | The exact date the cron requests should start. |
| number | period | The delay between subsequent requests in minutes. Minimum of 1 minute. |
| string | path | The path specified by the HTTP CRON requests. Maximum length of 100 characters. |
| object | params? | Optional parameters to be given with the HTTP CRON requests. Maximum of 256 bytes of data. |
| boolean | published? | Whether the CRON requests should be sent to the published version of the app, or the most recent preview version. By default only requests scheduled in published mode go to the published version of the app. |
| boolean | mailOnError? | Whether to email this app's owner if the cron request fails or is canceled; defaults to false. |
| string | A unique identifier for this cron task. |
result = schedule(new Date("Jan 12, 2008"), "/dosomething");
Returns an array of objects describing all scheduled CRON tasks. Modifications to these objects are not reflected in the scheduled tasks.
The returned objects have property names that are the same as
the arguments to schedule() and
scheduleRepeating(), namely:
- name: the task's identifier
- date: date the task is (or was) first scheduled to run
- period: delay between repeated requests, in minutes
- path: path to request
- params: query string containing the parameters on the request
- published: whether to send the request to the published or preview version of the code
- mailOnError: whether to send mail if there's an error
| Array | An array of objects describing all scheduled CRON tasks. |
name.
If the CRON task is non-repeating and has already been executed, this function has no effect.
| string | name | The identifier of the CRON task to cancel. |
result = schedule(new Date("Jan 12, 2008"), "/dosomething");
unschedule(result);