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.
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:
- Repost: All About Sitecore Scheduling: Agents and Tasks by John West
- Run Sitecore scheduled task at the same time every day by briancaos
- How To Set-Up A Scheduled Task In Sitecore by Jon D Jones
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.
LikeLike
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,
LikeLike
Pingback: Sitecore Scheduled Tasks – Run on certain server instance – Just another WordPress site
Pingback: Sitecore Scheduled Task – Schedule time format and other quirks | Brian Pedersen's Sitecore and .NET Blog
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
LikeLike
Pingback: Which of my old Sitecore posts are still valid in Sitecore 9? | Brian Pedersen's Sitecore and .NET Blog