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 ?
Comments
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,idfrom %SYS.Task
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 = 1001Set flag = 2Write##class(%SYS.Task).Suspend(taskId,flag)
Set taskId=1001Write##class(%SYS.Task).Resume(taskId)Thank you Ashok Kumar