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.
MarkLogic Server allows you to schedule the execution of XQuery main modules. The ability to schedule module execution is useful for:
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.
To schedule a module for invocation at a particular date/time or interval, do the following:
MarkLogic/Docs
, specify Docs
. If Task Modules is set to (file system), then place the module in the directory specified by Task Root. For example, in the configuration shown in Step 10, you would place the Scheduler_test.xqy file in the MarkLogic/Docs
directory.
If Task Modules is set to a database, then load the module into that database under the URI root specified by Task Root. For example, if the configuration shown in Step 10 specified the Documents
database in the Task Modules field, you could use the xdmp:document-load function to load the module with the following URI option:
<uri>Docs/Scheduler_test.xqy</uri>
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.
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:
The date/time options are scheduled in terms of the local time designated by the server's clock. This means that, in regions that recognize daylight savings time, a scheduling interval of 24 hours is not the same as a once-per-day at a particular time scheduling interval.
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:
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.
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:
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:
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:
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: