Sitecore Scheduled Tasks – Run on certain server instance

If you would like certain Sitecore Scheduled Tasks run on a certain server instance (your CM server for example) the approach is pretty simple.

First, create a new folder under /sitecore/system/Tasks. I have a new folder called “CMSchedules“. Place your Scheduled Tasks in this folder.

Scheduled Tasks in separate folder

Scheduled Tasks in separate folder

Then tell Sitecore to execute these tasks. Place the following configuration on the instance you wish should run these tasks. Do not place the configuration on servers that should not run the tasks.

You need to patch the Sitecore.config (for Sitecore 8.1 and up) or web.config (for versions prior to Sitecore 8.1). Add the following to the /sitecore/scheduling section:

<agent type="Sitecore.Tasks.DatabaseAgent" method="Run" interval="00:05:00">
  <param desc="database">master</param>
  <param desc="schedule root">/sitecore/system/Tasks/CMSchedules</param>
  <LogActivity>true</LogActivity>
</agent>

The configuration tells Sitecore to execute all tasks in the /sitecore/system/Tasks/CMSchedules every 5 minutes.

MORE TO READ:

 

Advertisements

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in Sitecore 5, Sitecore 6, Sitecore 7, Sitecore 8 and tagged , . Bookmark the permalink.

4 Responses to Sitecore Scheduled Tasks – Run on certain server instance

  1. jammykam says:

    In this example, you could also make the `CMSSchedules` folder unpublishable, so it would never be published to web and therefore only be available as a scheduled task on master.

  2. briancaos says:

    That would not make a difference as the scheduler always looks for the tasks in the MASTER database, never in the WEB database. The param database=master ensures this.
    But if you have configured your CD servers to now having access to the MASTER database, the CD server will not run the tasks. This still does not ensure that a reporting or aggregation server does not execute your tasks as these server profiles require access to the MASTER database,

  3. Pingback: Sitecore Scheduled Tasks – Run on certain server instance – Just another WordPress site

  4. Pingback: Sitecore Scheduled Task – Schedule time format and other quirks | Brian Pedersen's Sitecore and .NET Blog

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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