Written by

Question Nezla · Mar 31

Task scheduler

Hi,

I've a list of running scheduled task in task manger and would to crate a tasks to monitor if any of my tasks has stopped running, is there a function to check tasks status?  

Thanks 

Product version: IRIS 2024.3

Comments

Ashok Kumar T · Mar 31

Hello @Nezla,

The %SYS.Task class has the task details which includes the status of the task. The "Suspended" column has value if incase the task is errored out while running ("Suspend Leave" ) or the task is suspended ("Suspend Reschedule"). Based on this column you can find out the suspended /errored task. Use the below query for the TaskName and additional details.

selectName,Status,TaskClass,Suspended from %SYS.Task
0
Nezla  Mar 31 to Ashok Kumar T

Thanks Ashok

0
Phillip Wu  Apr 1 to Ashok Kumar T

Would this SQL be more accurate?
select Name,Status,TaskClass,Suspended from %SYS.Task <> 1
If not, why?

0
Phillip Wu  Apr 1 to Phillip Wu

Sorry left out the variable 'Status'

select Name,Status,TaskClass,Suspended from %SYS.Task where Status <> 1

0
Ashok Kumar T  Apr 1 to Phillip Wu

Hello @Phillip Wu

The "status" is set to 1 for tasks that are either currently suspended ("Suspended Reschedule") or encounter an error during execution. If the "Suspend task on error?" option is set to "no" when scheduling the task, the error message is stored in the status column. However, the task status is not suspended.

From documentation

If not defined by the task default success will be 1
If the job is currently running (JobRunning) Status will be -1
If there was an untrapped error (JobUntrappedError) Status will be -2
If there was an error before execution (JobSetupError) Status will be -3
If the task timed out trying to job (JobTimeout) Status will be -4
If there was an error after execution (JobPostProcessError) Status will be -5
The text of the status code will be in the property Error.
 

SQL Query

selectName,displaystatus,Error,Suspended,%IDfrom %SYS.Task Where Suspended=1or Suspended=2

 Query method

set tResult = ##class(%SYS.Task).TaskListFilterFunc("Suspend")
do tResult.%Display()
0