The administrative task scheduler

The administrative task scheduler enables Db2® database servers to automate the execution of tasks. It also provides a programmable SQL interface, which allows you to build applications that can take advantage of the administrative task scheduler.

The administrative task scheduler manages and runs administrative tasks, which must be encapsulated in either user-defined or built-in procedures. You can add, update and remove tasks from the scheduler's task list by using a set of built-in procedures. You can also monitor the task list and the status of executed tasks by using administrative views.

The administrative task scheduler operates independently of the IBM® Data Studio and Database Administration Server (DAS). It is included in Db2 database servers and is disabled by default. In order to successfully execute tasks, you must set up the administrative task scheduler.

Understanding how the scheduler executes tasks

Scheduled tasks are executed by the Db2 autonomic computing daemon, which also hosts the health monitor and automatic maintenance utilities. This daemon appears in the process list as db2acd and starts and stops in conjunction with the database manager. In a partitioned database environment, all tasks are executed from the catalog database partition.

Every five minutes the Db2 autonomic computing daemon checks for new or updated tasks. To do this, it briefly connects to each active database and retrieves the new and updated task definitions. In a partitioned database environment, the daemon restricts connections to the catalog database partition. The daemon does not connect to inactive databases. To ensure scheduled tasks are executed as expected, the database must remain active and the task's earliest begin time should be at least five minutes after it is created or updated.

Internally, the daemon maintains a list of the active tasks. When a task's scheduled execution time arrives, the daemon connects to the appropriate database and calls the procedure associated with the task. If the database is not active, the daemon will not execute the task; it writes an ADM15502W message in both the administration notification log and the db2diag.log. If, for some other reason, the daemon fails to execute the task, an ADM15501W message is written to both the administration notification log and the db2diag.log. The daemon then automatically attempts to execute the task every 60 seconds.

The daemon will never execute a task if a previous instance of the same task is still outstanding. For example, assume a task is scheduled to run every 5 minutes. If, for some reason, the task takes 7 minutes to complete, the daemon will not execute another instance of the task at the next 5 minute interval. Instead, the task will run at the 10 minute mark.

The execution status of the task is recorded by the scheduler and can be retrieved with the ADMIN_TASK_STATUS administrative view.