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 shows 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.

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.

Environment

ITMS 7.6, 8.0, 8.1

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