Last Update: Nov 19, 2024 | Published: Feb 17, 2014
A little-known feature of Windows failover clustering is the ability to schedule tasks against the cluster, instead of the normally per-server job. In this post I will explain scheduled cluster tasks and show you how to implement them.
Normally we run a scheduled task on a single machine. However, clusters are a little different. A cluster is a pool of computer resources that one or more highly available (HA) resources (file shares, SQL databases, virtual machines, and so on) will run on. The resources are mobile; a SQL database might be failed over on rare occasions or a virtual machine might live migrate on a regular basis. We might need a task to run on one or all of the cluster nodes. Maybe we don’t care which node. Maybe we need the task to follow a HA resource around the cluster. Or maybe we need the task to be run simultaneously on every node.
And that’s why Microsoft added clustered tasks in Window Server 2012 (WS2012).
There are three kinds of clustered task:
Note: Once created, you cannot modify the type of the clustered task; you will have to remove the original clustered task and create a new one of the desired type.
There is no UI for managing clustered tasks, as all administration is done using PowerShell. There are four PowerShell cmdlets to know of.
You will perform the following steps to create a new scheduled clustered task. Start by creating an action using New-ScheduledTaskAction.
$TaskAction = New-ScheduledTaskAction -Execute C:WindowsSystem32someprogram.exe
Then you will create a trigger to start the clustered task using New-ScheduledTaskTrigger:
$TaskTrigger = New-ScheduledTaskTrigger -At 01:00 -Daily
Next, create the new clustered task using the previously action and the trigger. There are three kinds of task type, and therefore three ways to create a clustered task.
Register-ClusteredScheduledTask -Cluster HVC1 -TaskName “An example any node Cluster Task” -TaskType AnyNode -Action $TaskAction -Trigger $TaskTrigger
Register-ClusteredScheduledTask -Cluster HVC1 -TaskName “An example resource specific Cluster Task” -TaskType ResourceSpecific -Resource AHAResource -Action $TaskAction -Trigger $TaskTrigger
Register-ClusteredScheduledTask -Cluster HVC1 -TaskName “An example cluster wide Cluster Task” -TaskType ClusterWide -Action $TaskAction -Trigger $TaskTrigger
Any clustered task that you create will appear in Task Scheduler under Task Scheduler Library > Microsoft > Windows > Failover Clustering.