Kentico Xperience 13 documentation and ASP.NET Core

Most documentation about running Xperience applications under ASP.NET Core can be found in a dedicated section: Developing Xperience applications using ASP.NET Core. The rest of the documentation still applies, but some code samples and scenarios might need slight modifications for Core projects.

All major differences between the MVC 5 and Core platforms are summarized in Migrating to ASP.NET Core.

×

Configuring scheduled task execution

This page explains how to configure execution of scheduled tasks. Scheduled tasks can be executed by:

  • The Xperience administration application.
  • The live site application that provides the presentation for a specific site (only supported for site-related tasks). To learn how to enable the scheduler for the live site, see Processing scheduled tasks on the live site.
  • A dedicated external Windows service (does not support tasks that require the context of Xperience or a general web application).

All approaches can be enabled at the same time and used to execute different scheduled tasks.

By default, all scheduled tasks are executed by the Xperience administration application.

Configuring execution by Xperience applications

The following section describes how to configure when the Xperience administration or live site applications run scheduled tasks.

The time when the system executes scheduled tasks is based on two levels of settings:

  • Task interval – configured for individual scheduled tasks, and determines when tasks are ready for execution.
  • Application scheduler interval – determines the time interval after which the application checks if any tasks are ready to be executed.

To configure the task interval for individual scheduled tasks:

  1. Open the Scheduled tasks application.
  2. Edit the scheduled task.
  3. Set the task's scheduling properties (Period, Start time, Every, Between, Days).
  4. Click Save.

The system checks if there are any tasks ready to be executed regularly according to an automatic timer, by sending internal requests to the ~/CMSPages/Scheduler.ashx system route. To configure how frequently these checks occur:

  1. Open the Settings application in the Xperience administration interface.
  2. Select the System category.
  3. Type a number of seconds into the Application scheduler interval setting.
    • Supported values are between 1 – 30 seconds (higher values default to 30). For example, a value of 30 means that the scheduler checks tasks every 30 seconds.
  4. Click Save.

Additional low-level scheduled task settings can be done via web.config keys listed in the Scheduler settings section of the Web.config application keys reference.

Request-based scheduler mode

The Xperience administration application supports an alternative scheduler mode, where the system checks scheduled tasks at the end of each standard page request. This means that tasks are only executed when user activity in the administration interface generates requests.

To enable this mode, add the CMSUseAutomaticScheduler key into the /configuration/appSettings section of your administration application's web.config file:

<add key="CMSUseAutomaticScheduler" value="false" />

In request-based mode, the Application scheduler interval setting sets the minimum time between the checks:

  • For example, a value of 60 means that the application checks after 60 seconds even if multiple page requests occur per minute. Tasks are NOT executed if there are no page requests.
  • 0 disables the execution of tasks by the application scheduler.

Note: The request-based scheduler is not available for the live site. On the side of the live site application, setting the key to false disables the scheduler.

Scheduler reliability

The scheduler used by the Xperience administration and live site applications runs within the ASP.NET process, so tasks cannot be executed if the corresponding web application is not running. The application stops running when the process is recycled without being started again (after a long period of website inactivity).

To ensure that scheduled tasks get processed regularly, we recommend the following:

  • Use the default automatic scheduler mode for the Xperience administration application.
  • Ensure that the Xperience application's worker process does not shut down if no one accesses the administration interface for a certain period of time. For example, set the Start Mode advanced setting of the used application pool in IIS to AlwaysRunning.

  • Use the Scheduler Windows service for supported tasks if possible. The external service always runs and executes tasks reliably.

Configuring execution by the Windows service

Xperience provides an external Windows service which can execute scheduled tasks. The advantage of the service is that it always runs reliably (as long as the entire server is running). However, scheduled tasks that require the context of Xperience or a general web application are not supported.

Enabling the Windows scheduler service

Prerequisite: You need to have the Scheduler Windows service installed and running.

  1. Open the Settings application.
  2. Select the System category.
  3. Enable the Use external service setting.
  4. In the Scheduled tasks application, enable the Use external service option for individual tasks.
    • Note: Only some of the default scheduled tasks are supported by the external service. The tasks that do not have the option available in the editing interface must be processed by the Xperience application.
    • For site-specific tasks, leave the Run task on property set to Administration (the external scheduling service is bound to the administration application, not the live site).
    • Tasks with the Use external service option disabled will be executed by the Xperience application.
    • If the Use external service setting in the Settings application is disabled, even tasks with the Use external service option enabled are processed by the Xperience application.

Setting the task execution time

The time when the Windows scheduler service executes scheduled tasks is based on two levels of settings:

  • Task interval – configured for individual scheduled tasks, and determines when tasks are ready for execution.
  • Application scheduler interval – determines the time interval after which the service checks if any tasks are ready to be executed.

To configure the task interval that for individual scheduled tasks:

  1. Open the Scheduled tasks application.
  2. Edit the scheduled task.
  3. Set the task's scheduling properties (Period, Start time, Every, Between, Days).
  4. Click Save.

To configure how frequently the Windows scheduler service checks if there are any tasks ready to be executed:

  1. Open the Settings application.
  2. Select the System category.
  3. Type a number of seconds into the Service scheduler interval setting.
    • Supported values are between 1 – 30 seconds (higher values default to 30). For example, a value of 30 means that the service checks tasks every 30 seconds.
  4. Click Save.

Was this page helpful?