Defining task schedules

You can use different combinations of parameters to define schedules for task executions.

Procedure

To define a new scheduled task:

Connect to the Db2 subsystem with sufficient authorization to call the ADMIN_TASK_ADD stored procedure.
The following task definitions show some common scheduling options.
To define Do this
A task that executes only one time:

Set max-invocations to 1.

Optionally, provide a value for the begin-timestamp parameter to control when execution happens. Leave other parameters null.

For example, if max-invocations is set to 1 and begin-timestamp is set to 2008-05-27-06.30.0, the task executes at 6:30 AM on May 27, 2008.

With this definition, the task executes one time. If begin-timestamp has been provided, execution happens as soon as permitted.

A regular repetitive execution:

Set interval to the number of minutes that you want to pass between the start of one execution and the start of the next execution.

Optionally, provide values for the max-invocations, begin-timestamp, and end-timestamp parameters to limit execution. Leave other parameters null.

For example, if interval is set to 5 and begin-timestamp is set to 2008-05-27-06.30.0, the task executes at 6:30 AM on May 27, 2008, then again at 6:35, 6:40, and so forth.

With this definition, the task executes every interval minutes, so long as the previous execution has finished. If the previous execution is still in progress, the new execution is postponed interval minutes. Execution continues to be postponed until the running task completes.

An irregular repetitive execution:

Set point-in-time to a valid UNIX cron format string. The string specifies a set of times.

Optionally, provide values for the max-invocations, begin-timestamp and end-timestamp parameters to limit execution. Leave other parameters null.

For example, if point-in-time is set to 0 22 * * 1,5, the task executes at 10:00 PM each Monday and Friday.

With this definition, the task executes at each time specified, so long as the previous execution has finished. If the previous execution is still in progress, the new execution is skipped. Subsequent executions continue to be skipped until the running task completes.

An execution that is triggered when another task completes:

Set trigger-task-name to the name of the triggering task. Optionally set trigger-task-cond and trigger-task-code to limit execution based on the result of the triggering task. The trigger-task-cond and trigger-task-code parameters must either both be null or both be non-null.

Optionally, provide values for the max-invocations, begin-timestamp and end-timestamp parameters to limit execution. Leave other parameters null.

For example, assume that a scheduled INSERT job has a task name of test_task. If trigger-task-name is test_task, trigger-task-cond is EQ, and trigger-task-code is 0, then this task executes when the INSERT job completes with a return code of 0.

With this definition, the task executes at each time specified, so long as the previous execution has finished. If the previous execution is still in progress, the new execution is skipped. Subsequent executions continue to be skipped until the running task completes.

An execution that is triggered when Db2 starts:

Set trigger-task-name to DB2START.

Optionally, provide values for the max-invocations, begin-timestamp and end-timestamp parameters to limit execution. Leave other parameters null.

For example, if trigger-task-name is DB2START, begin-timestamp is 2008-01-01-00.00.0, and end-timestamp is 2009-01-01-00.00.0, the task executes each time that Db2 starts during 2008.

With this definition, the task executes at each Db2 start, so long as the previous execution has finished. If the previous execution is still in progress, the new execution is skipped. Subsequent executions continue to be skipped until the running task completes.

An execution that is triggered when Db2 stops:

Set trigger-task-name to DB2STOP.

Optionally, provide values for the max-invocations, begin-timestamp and end-timestamp parameters to limit execution. Leave other parameters null.

With this definition, the task executes at each Db2 stop, so long as the previous execution has finished. If the previous execution is still in progress, the new execution is skipped. Subsequent executions continue to be skipped until the running task completes.