Change status of hung tasks showing as currently running
search cancel

Change status of hung tasks showing as currently running

book

Article ID: 162782

calendar_today

Updated On:

Products

IT Management Suite

Issue/Introduction

The currently running task reports show tasks which have been running for many days or months.  To change the task status from running to Failed or Completed, use the attached SQL statement.  This will cause the tasks to drop off the Currently Running Task report.

None recorded.

Environment

ITMS 7.6, 8.0, 8.1, 8.5, 8.6

Cause

There are multiple reasons a task might show as currently running but have timed out or stopped due to conflicts. For more information on task status issues, see HOWTO54534.

Resolution

To change the task status from Running to Failed or Completed, see the below SQL query.  The query searches for tasks that have been running longer than 7 days and changes the status to either 2 = Completed or 3 = Failed. 

Prior to 7.6, use the following query:

declare @daysold int
set @daysold = 7  --Set number of days task has been running

update tis set InstanceStatus = 2 -- 2 = Completed,  3 = Failed
from TaskInstances ti
join TaskInstanceStatus tis on tis.TaskInstanceGuid = ti.TaskInstanceGuid
where tis.InstanceStatus in (1,4)
and datediff(dd, ti.StartTime, getdate()) >= @daysold

 

For 7.6 and later:

  1. Find the tasks that are still running over 7 days for example

    declare @daysold int
    set @daysold = 7  --Set number of days task has been running
    select tis.*
    from TaskInstances ti
    join TaskInstanceStatus tis on tis.TaskInstanceGuid = ti.TaskInstanceGuid
    where tis.InstanceStatus in (1,4)
    and datediff(dd, ti.StartTime, getdate()) >= @daysold
     
  2. Using the results from the previous step, grab the "TaskInstanceGuid" for each task and use it with the following query:

    DELETE FROM TaskInstancesIncomplete
    WHERE TaskInstanceGuid = 'e4c37262-3bfb-4c91-97d5-cf3952792236' --Insert the Task Instance Guid, as you see in result of first query

 

For 8.6 and later

On recent releases, it is no longer needed for Customers to perform SQL queries to drop task instances in case those are hung. A customer can use the default mechanism to purge the required amount of task instances, task versions, etc. under Settings>All Settings>Notification Server>Task Settings:


When purging for task instances is started, then there is a set of stored procedures will be executed, like tmDeleteOrpanedTaskInstances, tmDeleteOrpanedTaskInstanceParents, tmDeleteOrpanedTaskOutputPropertyValue, and tmDeleteOrpanedTaskInstanceResultSummaries.

 

If the Customer is logged in to SMP Console using the default "Symantec Administrators" role, then on any opened task, there is a link to "view recent tasks". From this view, the Customer can multi-select and delete/stop unnecessary task instances