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:

 

Advertisement

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.

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

    Like

  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,

    Like

  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

  5. Larry R. says:

    We have a task that runs some days, but not other days.
    The log doesn’t show an error. When it doesn’t run, it shows:
    ManagedPoolThread #14 05:54:35 INFO Not due: Email a log file

    On days when it runs it shows this:
    ManagedPoolThread #2 05:49:42 INFO Starting: Email a log file
    ManagedPoolThread #2 05:49:43 INFO Ended: Email a log file

    Like

  6. Pingback: Which of my old Sitecore posts are still valid in Sitecore 9? | 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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.