SiteCron Integration: A Practical Guide

Updated Apr 8, 2024

When you need to perform repeated tasks in Sitecore CMS, you can either schedule jobs using the built-in mechanism or leverage a simpler alternative — the SiteCron module.

In this article, I would like to share my experience of integrating SiteCron as a separate Helix module by adding a new Feature project to an existing solution. In this way, we get compliance with the Helix principles and have the place to store our custom jobs.

What Is SiteCron?

SiteCron is a module by Akshay Sura used for running scheduled tasks (jobs) in Sitecore. It provides an advanced way to run Cron-based jobs using Sitecore and Quartz Scheduler, and the CronTrigger functionality to help you schedule both simple and complex tasks.

Basically, Sitecore has its own scheduling mechanism. It runs the jobs on the basis of the end time of the last run and over time; hence, there is a delay in the jobs triggering. If you need your jobs to run at a certain time, SiteCron is a good solution.

SiteCron Integration

1. Add a new Feature.Scheduler project in the solution.

2. Install the SiteСron nugget package.

You can see the list of files added to the project once the SiteCron package is installed.

SiteCron-integration-guide

Let’s see what these files are and what they are used for.

  • Z.SiteCron — configuration files. We will leave them as they are.
  • SiteCron.aspx — a jobs viewer, the page where you can see your scheduled tasks.
SiteCron-integration-guide
  • Konabos.Minions.RunMinion.dll — as per the documentation, you should include this as part of commerce deployment. Also, there is a sample job that shows you how to run a minion on a schedule in the SiteCron source on GitHub.
  • SitecorePackage — contains FULL and Items Only Sitecore packages. Use SiteCron FULL Sitecore Package.zip if you want to install the module onto your Sitecore environment without creating an additional module in your solution. This will prevent you from installing the SiteCron nugget package into your solution. That is the fastest way to start working with SiteCron. Personally, I prefer a SiteCron Items Only Sitecore Package.zip and the NuGet package combination with further integration of Feature.Scheduler into the CI process, and using the project to store my custom jobs.

3. Install SiteCron Items Only Sitecore Package.zip in Sitecore.

4. Update Unicorn configuration and serialize SiteCron items.

You should also be careful with content deployment and ensure that items are not lost during deployment. Looking into the SiteCron Items Only Sitecore Package.zip package, you can easily define what items need to be serialized. Below is an example of the Unicorn configuration for syncing items.

5. Update CI configuration to deploy the Feature.Scheduler project.

This step depends on the deployment workflow you follow. But in my case, I just added new publish profiles in the Feature.Scheduler project and made a few changes in the deployment script.

SiteCron-integration-guide

We are done with the installation and deployment setup. SiteCron is now in your solution. You should be able to open the /sitecore/admin/SiteCron.aspx page in your browser and create new jobs under /sitecore/system/Modules/Sitecron.

SiteСron Job Example

Let’s take a look at how to create and configure a new job. As an example, I’ll take the SmartSitePublishJob provided by the module author. It is quite simple and straightforward, so I will not dwell on its implementation. The main thing is that you can write your own custom implementation of the Execute method.

Job is a class inherited from the Quartz.IJob interface. The Execute method runs when the job is triggered and contains custom code which does the job.

Let’s copy the code as it is to our project, and just slightly correct Namespace.

Now, let’s add a new SiteCron Job to Sitecore.

SiteCron-integration-guide

Move on to the settings. The job calling interval is set up by using Cron expressions. Let’s say we want the job to run every Wednesday at 12:00 pm, so the expression should look like “0 0 12? * WED”. More examples and detailed parameter descriptions can be found on the Quartz Scheduler website.

SiteCron-integration-guide

Your job will now run according to the specified schedule and will be displayed on the jobs viewer page.

SiteCron-integration-guide

Conclusion

In this article, we reviewed an example of SiteCron integration within a separate Feature module into an existing solution. Generally speaking, this module works like a charm and is an excellent solution for running scheduled jobs.

The source code is available on Github.

6 Comments
Leave a comment
  • This is an informative post. Got a lot of info and details from here. Thank you for sharing this and looking forward to reading more of your post.

  • Raman, thank you for this helpful information. I’ve installed Sitecron in our production environment following your guide and it works!

  • I agree that SiteCron is a really useful module. For precision complex scheduling in Sitecore, SiteCron is probably the best option.

  • Cool, as part of a separate feature module. Thanks for the code on Github, will try to implement it in my project.

  • Thank you! You were just in time with this guide, I needed to integrate SiteCron into my project, and your article helped a lot.

  • I worked with SiteCron and can say that this is one of the most useful things I’ve ever used in my Sitecore-based projects.

Leave a Comment

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>