DB2 Version 10.1 for Linux, UNIX, and Windows

Defining task schedules for the administrative task scheduler

Use different combinations of arguments to define schedules for tasks in the administrative task scheduler.

About this task

The following arguments are available in the ADMIN_TASK_ADD and ADMIN_TASK_UPDATE procedures to control when scheduled tasks execute:
  • begin_timestamp, the earliest permitted execution time
  • end_timestamp, the latest permitted execution time
  • max_invocations, the maximum number of invocations
  • schedule, the task execution schedule

The begin_timestamp and end_timestamp arguments are timestamps that define a window of time during which tasks can start. Before and after this window, the task will not start even if the schedule argument is met. If begin_timestamp is NULL, the window begins at the time when the task is added, and executions can start immediately. If end_timestamp is NULL, the window extends infinitely into the future, so that repetitive or triggered executions are not limited by time. Timestamps must either be NULL values or future times, and end_timestamp cannot be earlier than begin_timestamp.

For repetitive tasks, the number of executions can be limited using the max_invocations argument. In this case, the task executes no more than the number of times indicated by the argument, even if the schedule and the window of time would require the task to be executed. Executions that are skipped because they overlap with previous executions that are still running are not counted toward max_invocations.

The max_invocations argument defines a limit but no requirement. If the task is executed fewer times than indicated during its execution window, the maximum number of executions will never be reached.

Procedure

The following task definitions show some common scheduling options:
To define Do this
A task that executes one time only Set max_invocations to 1.

Optionally, provide a value for the begin_timestamp argument to control when execution happens.

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 the schedule argument to a valid UNIX cron format string that specifies the interval 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 arguments to limit execution.

For example, if schedule is set to '0 * * * *' and begin_timestamp is set to 2008-05-27-06.30.0, the task executes at 7:00 AM on May 27, 2008, then again at 8:00, 9:00, and so forth.

If the previous execution is still in progress, the new execution is postponed until the running task completes.

An irregular, repetitive execution Set the schedule argument to a valid UNIX cron format string that specifies a set of times.

Optionally, provide values for the max_invocations, begin_timestamp and end_timestamp arguments to limit execution.

For example, if schedule 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.