Sitecore Scheduler

Sitecore scheduler is task that gets executed at some interval. There are three ways to schedule process in Sitecore CMS.

1) Configure agent in web.config

This is very straightforward and the most common way to create a scheduler in Sitecore. Using this approach will restart ASP.NET worker process as it requires to change web.config file.

Each /configuration/sitecore/scheduling/agent element defines an agent.

  • The type attribute of each <agent> 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.

Sitecore passes parameters to the constructor of the agent class and sets properties of that object in the same way it does for any other type defined in web.config.

To create a custom agent, just create a class that implements a method, and register that class as an agent. Here’s an example class:

namespace Sitecore.Sharedsource.Tasks 
  public class LogSomethingAgent 
    public string Message 
    public void Run() 
      Sitecore.Diagnostics.Log.Info(this + " : " + this.Message, this); 

After setting the value of the <frequency> element to one minute (00:00:30), here’s how I configured the agent in web.config for testing:

<agent type="Sitecore.Sharedsource.Tasks.LogSomething" 
  <message>Hello, World!</message> 

With the default Sitecore verbosity level, Sitecore logs the invocation of each agent. So Sitecore actually writes three lines to the log each time it invokes this agent. For example:

ManagedPoolThread #8 13:05:11 INFO  Job started: Sitecore.Sharedsource.Tasks.LogSomethingAgent
ManagedPoolThread #8 13:05:11 INFO  Sitecore.Sharedsource.Tasks.LogSomethingAgent : Hello, World!
ManagedPoolThread #8 13:05:11 INFO  Job ended: Sitecore.Sharedsource.Tasks.LogSomethingAgent

2) Create schedule tasks in Sitecore database

In this option, you can define scheduler in Sitecore database under /sitecore/system/Tasks/Schedules. This option is user-friendly as you can configure scheduling option from CMS directly. This approach would not restart ASP.NET worker process as you don’t require to change web.config file


3) Create Window Task Scheduler (window service) to call web service in Sitecore


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s