Listing multiple execution statuses of scheduled tasks

You can use the ADMIN_TASK_STATUS table function with the max-history parameter to view multiple execution statuses of scheduled tasks.

About this task

The ADMIN_TASK_STATUS(MAX_HISTORY) table function returns a row of data for the most recent executions of each task (up to the max-history value). This function contacts the administrative task scheduler to update the Db2 task list in the SYSIBM.ADMIN_TASKS table and the status history for the task in the SYSIBM.ADMIN_TASKS_HIST table, if necessary, and reads the task statuses from theses tables.

To prevent the SYSIBM.ADMIN_TASKS_HIST table from containing too many status entries, the administrative task scheduler limits the number of status entries per task that are stored. This limit is specified by the MAXHIST parameter. This parameter is a positive integer with a default value of 10. When the limit is reached, the oldest status entries are deleted. You can specify this parameter in the started task when the administrative task scheduler starts, or you can modify this parameter dynamically by using the MODIFY console command.

Procedure

To list multiple execution statuses of scheduled tasks:

  1. Issue the ADMIN_TASK_STATUS(MAX_HISTORY) table function to generate the status table.
    The max-history parameter specifies the number of execution statuses that you want to view.
  2. Select the rows in the table that correspond to the task name.

    To order the execution statuses, you can use the NUM_INVOCATIONS and START_TIMESTAMP columns in the table that is returned.

    If a task ran fewer times than the max-history value, this function returns all of the execution statuses. If the SYSIBM.ADMIN_TASKS_HIST table is not available, this function returns only the last five execution statuses for each task. If a task has not run yet, a row of data is returned with all columns containing null values, except that the TASK_NAME column contains the name of the task.

    Tip: You can relate the task execution status to the task definition by joining the output tables from the ADMIN_TASK_LIST and ADMIN_TASK_STATUS(MAX_HISTORY) table functions on the TASK_NAME column.