How can I configure scheduled tasks in Sitecore to only run on one of the machines in a load balanced content management (CM) environment?

I have a task configured via a config include and am using Sitecore 8.0.

  • Matthew look in to Sitecron - akshaysura.com/?s=sitecron it has the capability to run on one instance if you configured the scalability settings.
    – ASura
    Sep 23, 2016 at 14:24

3 Answers 3


I would suggest switch to Database Tasks (/sitecore/system/Tasks/Schedules/), it has out-of-box mechanism to handle scheduled tasks for load balanced environments.

The benefit you will have is, it will get invoked only from one of multiple sitecore instance (whatever instance gets first chance) as it maintains state (flag) of Last Run.

For example, if the scheduler was run from instance A at 9:00:00. Now, assume that after few minutes, instance B checks to run it, before that it will check the last run time and will compare with the Schedule field (To check frequency of scheduler), and skip its execution as it's already been executed by machine-A.

Make sure to make it Async to avoid time-overlapping between two instances as Last run field considers Task ending time. So, if you set it as Async, the starting and end time will be same, and will give more accuracy.

enter image description here

Reference for using it - http://www.degdigital.com/insights/how-to-create-sitecore-scheduled-task/

  • Yeah, this is probably more inline with what you want to use. =)
    – Pete Navarra
    Sep 23, 2016 at 14:19

Config based tasks will run on the server that it is configured to run on by the presence of the task in its config. In a load balanced CM environment, if you have a config task that you only want to run on 1 CM server, then have it only show up in the config on one of the servers.

Okay, that's the easy way but what if one of the CM servers goes down? You still want the task to run.

In that case, I suggest changing the way the task runs so that it sets a running flag in a db somewhere as soon as it starts. In other instances, it checks that flag before running and if it exists it stops running.

  • Interesting suggestion about setting a running flag in the DB. Do you know of a way to do that via the API ? Sep 23, 2016 at 10:46
  • 2
    There's a couple ways to shave that yak. 1) Create an item in master or core that holds the flag. 2) use a custom DB to hold it. I'll see if I can find some other interesting api ways once I get to a computer.
    – Pete Navarra
    Sep 23, 2016 at 10:48

If you want the task to run only on one dedicated machine you can disable the task agent according to the John's blog post:

Each /configuration/sitecore/scheduling/agent element defines an agent. The type attribute of each element specifies the .NET class to invoke. The method attribute defines the method of the class that Sitecore will call. The interval attribute defines the minimal interval between invocations of the agent in HH:mm:ss format. A value of 00:00:00 for the interval attribute disables an agent. Comments above the agent definitions in the web.config file describe their functions.

The downside of this solution is that when this machine will not be working your tasks will not run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.