Sitecore start scheduled task manually

Sitecore scheduled tasks are background tasks running on a schedule. But never when you need it, especially when developing the tasks. You can trigger these tasks manually if you please.

THE EASY WAY: INSTALL SITECORE POWERSHELL

The Sitecore PowerShell module have a built in task runner. When installed, you can right click the task you wish to run and click “Run Task Schedule

Powrshell Run Task

Powrshell Run Task

THE FUN WAY: PROGRAM YOUR OWN TASK STARTER:

You can, of course, write your own task runner, create a nice scheduled task page, and display all possible tasks where you can start them individually:

Scheduled Tasks List

Scheduled Tasks List

To get a list of all scheduled tasks:

private const string SCHEDULED_PATH = "/sitecore/system/Tasks//*[@@templatename='Schedule']";
  
foreach (Item item in Sitecore.Context.Database
  .SelectItems(SCHEDULED_PATH)
  .OrderBy(t => t.Parent.Name)
  .ThenBy(t => t.Name))
{
  ScheduleItem scheduleItem = new ScheduleItem(item);
  // Do stuff with the scheduleItem
}

To start a scheduled task:

Sitecore.Tasks.ScheduleItem scheduleItem = new Sitecore.Tasks.ScheduleItem(item);
scheduleItem.Execute();

MORE TO READ:

About briancaos

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

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

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