Loading TOC...
Administrator's Guide (PDF)

MarkLogic 10 Product Documentation
Administrator's Guide
— Chapter 31

Scheduling Tasks

This chapter describes how to schedule tasks that execute XQuery main modules at a predefined date/time or interval. The following topics are included:

This chapter describes how to use the Admin Interface to manage scheduled tasks. For details on how to manage scheduled tasks programmatically, see Group Maintenance Operations in the Scripting Administrative Tasks Guide.

Understanding Scheduled Tasks

MarkLogic Server allows you to schedule the execution of XQuery main modules. The ability to schedule module execution is useful for:

  • Loading content. For example, periodically checking for new content from an external data source, such as a web site, web service, etc.
  • Synchronizing content. For example, when MarkLogic is used as a metadata repository, you might want to periodically check for changed data.
  • Delivering batches of content: For example, initiate an RSS feed, hourly or daily.
  • Delivering aggregated alerts, either hourly or daily.
  • Delivering reports, either daily, weekly, or monthly.
  • Polling for the completion of an asynchronous process, such as the creation of a PDF file

Tasks can be scheduled to run at a particular time on a particular date, or at a specified interval. MarkLogic Server attempts to place the task on the task server's queue at the specified time, but the actual execution of the task might not start at this time. If the queue is full, the task fails and will not be re-tried until the next scheduled interval.

Scheduling a Module for Invocation

To schedule a module for invocation at a particular date/time or interval, do the following:

  1. Click the Groups icon in the left tree menu.
  2. Click on the group in which you want to schedule a task (for example, Default).
  3. Click the Scheduled Tasks icon on the left tree menu.
  4. Click on the Create tab to bring up the Schedule a Task page
  5. Specify the URI for the module to invoke in the Task Path field. The task path must begin with a forward slash (/) and cannot contain a question mark '?', colon ':' or pound '#' character.
  6. In the Task Root field, specify the root directory (files system) or URI root (database) that contains the module.
  7. In the Task Type field, select one of the task types described in Selecting a Task Type.
  8. In the Database field, select the database on which to invoke the module.
  9. In the Task Modules field, select either the file system or database that contains the module specified in the Task Path field.

    If Task Modules is set to (file system), then place the module in or below the directory specified by Task Root. The file will be located on disk with a path that is the Task Root combined with the Task Path. For example, if the Task Root is /marklogic/modules and the Task Path is /tasks/test.xqy, then test.xqy should be located at /marklogic/modules/tasks/test.xqy on the file system.

    If Task Modules is set to a database, then load the module into that database at or under the URI root specified by Task Root. For example, for the configuration shown in Step 10, test.xqy should be inserted in the Modules datase at URI /marklogic/modules/test.xqy.

  10. In the Task User and Task Host fields, specify the user with permission to invoke the task and the host computer on which the task is to be invoked. If no host is specified, then the task runs on all hosts.

    The user specified in the Task User field must have the privileges required to execute the functions used in the module. See Appendix B: Pre-defined Execute Privileges for the full list of execute privileges.

    Example of a Scheduled Task configuration:

Selecting a Task Type

You can select one of the date/time or interval scheduling options described in this section as your task type.

The interval scheduling options that operate on elapsed time are:

The date/time scheduling options that operate on calendar time are:

Scheduling Per Minute

If you select minutely task type, specify how many minutes are to elapse between each invocation of the module. For example, to invoke the module every 5 minutes (or as soon as possible thereafter, if the server is overloaded), enter:

Scheduling Per Hour

If you select hourly task type, specify how many hours are to elapse between each invocation of the module. The Task Minute setting specifies how many minutes after the hour the module is to be invoked. Note that the Task Minute setting does not add to the interval.

For example, to invoke the module every 2 hours at 30 minutes past the hour (or as soon as possible thereafter, if the server is overloaded), enter:

If the current time is 2:15pm, the task will run at 2:30, 4:30pm, 6:30pm, 8:30pm, and so on.

Scheduling Per Day and Time

If you select daily task type, specify how many days are to elapse between each invocation of the module and the time of day (in 24:00 notation) of the invocation.

For example, to invoke the module every three days at 12:00pm, enter:

Scheduling Per Week, Day, and Time

If you select weekly task type, specify how many weeks are to elapse between each invocation of the module, as well as one or more days of the week and time (in 24:00 notation) of the invocation.

For example, to invoke the module every other week, on Friday, at 5:00pm, enter:

Scheduling Per Month, Day, and Time

If you select monthly task type, specify how many months are to elapse between each invocation of the module, as well as the day of the month and time (in 24:00 notation) of the invocation.

For example, to invoke the module every three months, on the 15th day of the month, at 8:00am, enter:

Scheduling One Invocation on a Calendar Date and Time

If you select once task type, specify the calendar day (month/day/year) and time (in 24:00 notation) of the invocation.

For example, to invoke the module on May 2, 2009 at 6:00pm, enter:

« Previous chapter
Next chapter »