How to Schedule Tasks on Sitecore?

Sitecore has its own task scheduler and we can schedule any tasks or jobs on Sitecore. The approach to schedule tasks on Sitecore is pretty simple. Follow the steps mentioned below and you should be able to schedule and run any tasks in Sitecore

How to Schedule Tasks on Sitecore?

Step 1: Login to Sitecore content editor and navigate to the Tasks section in the content tree.

Step 2: Create a folder under Tasks item and name it accordingly. In this example am naming it as MyTasksSchedules.

Step 3: The next step is to execute the tasks. We need to add the information about the task and the scheduling time in the web.config. This config should only be placed on the servers where you need to run the task.

If you are using Sitecore 8.1 and above then you would need to patch to the web.config manually. Create a config named SitecoreTasks.config and place it in the App_config/Include folder.

Add the below config section and provide the agent type properly. Agent type is nothing but the namespace and class name of the task you created.

The configuration above tells Sitecore to run the Job every 1 minute. The polling frequency determines how often Sitecore checks for agents that it needs to invoke. You can control the polling frequency by setting the value of the /configuration/sitecore/scheduling/frequency element in the web.config file (in HH:mm:ss format). I like to set the polling frequency to half of the value of the smallest value of the interval attribute of all the agents defined in the web.config file.

The custom agent code can be created by creating a simple class that implements a method. The same needs to be registered in the web.config as shown above.

Eg:

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *