BPMTasksCleanup command

Use this command to delete completed tasks from running process instances on IBM® Process Server.

Sometimes long running process instances can build up many completed task instances. The BPMTasksCleanup command deletes these tasks to improve system performance. Deleting these tasks also reduces the time that it takes to migrate process instances.

In general, start by deleting completed system and decision tasks. Consider deleting completed user tasks only if you need further performance improvements because deleting user tasks before the process instance completes could distort duration statistics for users who worked on those tasks. If the process instance has completed, use the BPMProcessInstancesCleanup command instead. The BPMProcessInstancesCleanup command deletes all tasks including user tasks. Another difference between BPMTasksCleanup and BPMProcessInstancesCleanup command is that BPMTasksCleanup does not delete tasks from the Process Portal index. For information about the Process Portal index, see Administering the Process Portal index.

Run the BPMTasksCleanup command by using the AdminTask object of the wsadmin scripting client.
Note: In an environment with multiple security domains configured, use the PALService MBean instead of this wsadmin command. See The Process Application LifeCycle (PAL) MBean.

Prerequisites

The following conditions must be met:
  • Run the command in the connected mode; that is, do not use the wsadmin -conntype none option.
  • You can run the command from any cluster member in a network deployment environment. However, you must first establish the wsadmin session to the SOAP port of the cluster member from where you are running the command.
  • To access the wsadmin command, the ID being used must have a WebSphere® Application Server role with more privileges than the monitor role. See Administrative roles for information about roles.
  • To access the IBM BPM API used by this command, the ID being used must belong to either the bpmAdminGroup or bpmAuthorGroup. The default name for the bpmAdminGroup is tw_admins and the default name for the bpmAuthorGroup is tw_authors. See IBM Business Process Manager default group types for information about groups.
    Tip: By default, only the DeAdmin user has both the WebSphere Application Server administrator role and membership in the bpmAdminGroup.

Location

Start the wsadmin scripting client from the install_root/bin directory.

Syntax

BPMTasksCleanup 
[-containerAcronym container_acronym]
[-containerSnapshotAcronym container_snapshot_acronym]
-taskStatus task_status
[-processName process_name]
[-taskType task_types]
[-taskID task_IDs]
[-endedAfterLocal local_time_on_the_server]
[-endedBeforeLocal local_time_on_the_server]
[-outputFile file_path]
[-maximumDuration number_of_minutes]
[-transactionSlice number_of_tasks_to_delete_in_a_transaction]

The tasks that are deleted by this command conform to all of its parameters. That is, if you provide a set of task IDs and set taskStatus to CLOSED, the command deletes only the identified tasks if they are closed. If they have a different status, the command does not delete them.

Parameters

-containerAcronym container_acronym
A parameter that contains the acronym of the container that the command searches in for completed tasks. If you do not include the taskID parameter, you must define this parameter.
-containerSnapshotAcronym container_snapshot_acronym
A parameter that contains the acronym of the snapshot in the container that the command searches in for completed tasks. If you do not include the taskID parameter, you must define this parameter. If you do not want to specify a snapshot, use the following value: Tip.
-taskStatus task_status
A required parameter that identifies what status a task must have to be deleted. Valid values are:
  • CLOSED
  • SENT
  • ACTIONED
  • DELETED
  • ALL_COMPLETED - Deletes all closed, sent, actioned, and deleted tasks.
-processName process_name
An optional parameter that identifies the specific process in the container that will have its tasks cleaned up. The default action is to clean up the tasks of all processes in the container.
-taskType task_types
A parameter that identifies which types of tasks to delete. Valid values are:
  • SYSTEM_TASK
  • USER_TASK
    Tip: In some scenarios, deleting user tasks before the process completes might distort statistics about the average duration that user worked on such tasks in the past.
  • DECISION_TASK
  • ALL
Restriction: The ALL value is the only valid value to delete tasks created in the versions of IBM BPM prior to 8.5.6.0 and subsequently migrated. This restriction occurs because distinguishing between task types for these migrated tasks is not supported.
-taskID task_IDs
A parameter that contains the ID of one or more tasks to delete from the runtime database. If you are providing multiple task IDs, separate each task ID by using a space for Jython format or by using a semicolon for Jacl format. If you do not define this parameter, the command uses the other parameters to determine which tasks to delete.
-endedAfterLocal local_time_on_the_server
An optional parameter of type String that identifies the local time on the server. The string must have the following format: yyyy-MM-ddThh:mm:ss (year, month, day, T, hours, minutes, seconds). Only tasks that have a specific taskStatus value on or after the specified time period are processed. If you use this parameter with the endedBeforeLocal parameter, only tasks that have a specific taskStatus value during the specified time period are processed.
-endedBeforeLocal local_time_on_the_server
An optional parameter of type String that identifies the local time on the server. The string must have the following format: yyyy-MM-ddThh:mm:ss (year, month, day, T, hours, minutes, seconds). Only tasks that have a specific taskStatus value on or before the specified time period are processed. If you use this parameter with the endedAfterLocal parameter, only tasks that have a specific taskStatus value during the specified time period are processed.
-outputFile file_path
An optional parameter that identifies the file on the connected server that contains the messages that are related to running this command. The path to the file can be absolute or relative. The default file is the systemout.log file on the connected server.
-maximumDuration number_of_minutes
An optional parameter that specifies the maximum time in minutes for the system to run the command. The default is 0 (no limit). If the time reaches the maximum, the system completes the current transaction, records a message in the log file, and then stops the command. If you set the transactionSlice parameter to a high number, the system could exceed the maximum duration to complete the transaction. If the system must complete the command by the maximum duration time, consider using a lower transactionSlice value.
-transactionSlice number_of_tasks_to_delete_in_a_transaction
An optional parameter that specifies the number of completed tasks to delete per transaction. When the number of tasks being deleted reaches the parameter value, the system completes the transaction and then starts a new transaction to resume deleting tasks. The default transactionSlice value is 100. Increasing the parameter value can improve the cleanup performance but risks a timeout. If a timeout occurs, the system reduces the transaction slice and records a message in the log file.

Examples

The following examples show how to use the BPMTasksCleanup command.

Important: In a network deployment environment, use the port that is configured for the application cluster member that runs the Process Server or Process Center applications. To determine the correct port number, see the administrative console ports collection page (click Servers > Server Types > WebSphere application servers > server_name > Communications > Ports and find the value for SOAP_CONNECTOR_ADDRESS).
  • Deleting the closed tasks for all of the processes in snapshot V1 of the PA435 process application:
    wsadmin -conntype SOAP -port 8880 -host ProcessServer01.mycompany.com -user admin -password admin -lang jython 
    
    wsadmin>AdminTask.BPMTasksCleanup('[-containerAcronym PA435 -containerSnapshotAcronym V1 -taskStatus CLOSED -outputFile C:\US58626\log1.txt]')
     
  • Deleting the specified tasks if they are complete:
    wsadmin -conntype SOAP -port 8880 -host ProcessServer01.mycompany.com -user admin -password admin -lang jython 
    
    wsadmin>AdminTask.BPMTasksCleanup('[-taskStatus ALL_COMPLETED -taskID [4 5 1001 1002]]') 
    
  • Deleting all tasks with CLOSED status before the specified date on the server in an allotted time of 60 minutes. The increased transactionSlice helps performance but risks that the command might run for longer than 60 minutes to complete its final transaction:
    wsadmin -conntype SOAP -port 8880 -host ProcessServer01.mycompany.com -user admin -password admin -lang jython 
    
    wsadmin>AdminTask.BPMTasksCleanup('[-taskStatus CLOSED -endedBeforeLocal 2014-01-02T21:37:06 -maximumDuration 60 -transactionSlice 200]') 
  • Deleting all completed tasks in a specified process:
    wsadmin -conntype SOAP -port 8880 -host ProcessServer01.mycompany.com -user admin -password admin -lang jython 
    
    wsadmin>AdminTask.BPMTasksCleanup('[-taskStatus ALL_COMPLETED -processName billPaymentProcess]')