Question
· Mar 5

Enable/Disable a scheduler task

Hi ,

I have a scheduler task and an associated class that works.

Class Sample.Util.CreateTask Extends (%SYS.Task.Definition, %Persistent)
{

Parameter PROPERTYVALIDATION = 1;

Parameter TaskName = "Sample.Util.CreateTask";

Method OnTask() As %Status
{
// Perform the logic
}

}

Is there a way to Enable or Disable the above task "CreateTask()" from an external function/Method/class ?

Discussion (2)1
Log in or sign up to continue

Hello @Krishnaveni Kapu 

%SYS.Task is responsible for store, suspend and resume for all the tasks. so, your can execute the below method programmatically to achieve it. It expects the task id as the first argument

You can execute the below query to get the task id, name and additional information

select Suspended,Name,id from %SYS.Task

suspend

Flag

1 - Suspend the task, but leave it in task queue (default)
2 - Suspend the task, remove from task queue, and reschedule for next time

Set taskId = 1001
Set flag = 2
Write ##class(%SYS.Task).Suspend(taskId,flag)

resume

Set taskId=1001
Write ##class(%SYS.Task).Resume(taskId)