GLOBAL INDEX  |  FRAMES  |  NO FRAMES
Library: cron
Overview
A collection of utilities for scheduling tasks in the future.
source: cron.js
Functions
schedule(date, path, params, published, mailOnError)

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.

parameters
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.
returns
string A unique identifier for this cron task.
examples
result = schedule(new Date("Jan 12, 2008"), "/dosomething");
function cron_dosomething() {
  sendEmail("you@example.com", "A scheduled message.", "Greetings!");
}
scheduleRepeating(date, period, path, params, published, mailOnError)

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.

parameters
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.
returns
string A unique identifier for this cron task.
examples
result = schedule(new Date("Jan 12, 2008"), "/dosomething");
listAll()

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
returns
Array An array of objects describing all scheduled CRON tasks.
unschedule(name)
Unschedules the CRON task identified by name.

If the CRON task is non-repeating and has already been executed, this function has no effect.

parameters
string name The identifier of the CRON task to cancel.
examples
result = schedule(new Date("Jan 12, 2008"), "/dosomething");
unschedule(result);
unscheduleAll()
Unschedules all CRON tasks.
Generated by JsDoc Toolkit 1.3.3 on Thu, 15 May 2008 16:56:37 GMT.