Windows Server 2012 Scheduled Cluster Tasks

Posted on February 17, 2014 by Aidan Finn in Windows Server 2012 with 0 Comments

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.

Why Do We Need Scheduled Cluster Tasks?

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).

Sponsored

Types of Clustered Task

There are three kinds of clustered task:

  • Any Node: One scheduled task is created in the cluster, and it runs on one node in the cluster. This might be useful if you have a query type of task or an operation that is run cluster-wide from a single point.
  • Resource-specific: One instance of the scheduled task is created and bound to a HA cluster resource. The task will execute on the cluster node on which the HA resource is running. This might be useful if you need to manipulate the resource before/after doing an operation. Removing the resource will trigger the automatic removal of the resource-specific clustered task.
  • Cluster-wide: One instance of the scheduled task is created on exists on every node in the cluster. The task will run on each node at the same time. This sort of cluster task is used when you need to run a per-server operation on each node in the cluster at the same time.
three kinds of clustered sheduled task

The types of scheduled 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.

Sponsored

Creating and Managing Cluster Tasks

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.

Then you will create a trigger to start the clustered task using New-ScheduledTaskTrigger:

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.

  • The first example will create a simple clustered task that will run on any node in a cluster called HVC1:

  • The second example will create a resource specific task that will follow a HA resource called AHAResource around the cluster:

  • The third example will create a clustered task that will run on all nodes at the same time:

Any clustered task that you create will appear in Task Scheduler under Task Scheduler Library > Microsoft > Windows > Failover Clustering.

Sponsored

Tagged with , , , , ,