dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.2k stars 191 forks source link

Support For Clustered Tasks ? #983

Closed kedar-hatkar closed 5 months ago

kedar-hatkar commented 5 months ago

I have node 1 and node 2 in fail over cluster with one resource configured in Windows server 2022 Standard edition. Both node has same domain user with full admin rights.

I have created fail over cluster task ( resource specific ) which gets trigger from node having active resource. https://techcommunity.microsoft.com/t5/failover-clustering/how-to-configure-clustered-tasks-with-windows-server-failover/ba-p/371784

Hence node 1 task is in ready state and node 2 task is in disabled mode

Now i have used this TaskSchedular nuget package (2.10.1.0) in Asp.net Web api 2 project which is hosted on node 1 IIS. In api logic, i am trying to update cluster task trigger time.

TaskService taskservice = new TaskService("ClusterName", "DomainUsername", "DomainName", "DomainPassword"); var task = taskservice.FindTask("runperiodiccleanup"); var trc = task.Definition.Triggers;
trc[0].Repetition.Interval = TimeSpan.FromMinutes(30); task.RegisterChanges();

i have given valid ClusterName which resolves to IP for fail over cluster IP ( different from node 1 and node 2 )

when i call my api from postman, I can see node 1 cluster task time is updated with new interval properly. But node 2 cluster task time is not getting updated. it remains at old interval.

If i manually update task trigger time from windows task scheduler on any node then i can see interval updated on both node 2

1) does library support updating cluster task ? or any code is my logic is missing ?

2) For now , i can write code twice to update task trigger by specifying individual node ip in targetServer property

TaskService taskservice1 = new TaskService("node1ip", "DomainUsername", "DomainName", "DomainPassword");

TaskService taskservice2 = new TaskService("node2ip", "DomainUsername", "DomainName", "DomainPassword");

but it would be useful if i pass Cluster Name or Cluster resource in target server property and task changes reflected on both node

dahall commented 5 months ago

No. Currently cluster support is only exported to the PowerShell library.