World is now on Opti ID! Learn more


Apr 26, 2012
  3162
(0 votes)

EPiServer Schedule Job Maintenance EPiServer CMS 6

In the past I have been plagued with issues where EPiServer scheduled jobs have suddenly stopped working and get stuck in a running state.  This is possibly caused by application restarts/redeployments while jobs are in progress and many other issues.

I am pretty sure these particular issues may well have been fixed in hotfixes or service packs, but from past experience I have become very cautious about scheduled jobs and there reliability especially if you are using them for site critical functionality.

Because of my scepticism about scheduled job reliability I have knocked together a class which should get a job up and running if it gets stuck in a running state.

My Solution

Firstly you will have to download this class ScheduledJobMaintenance.cs and add it to your solution.

You will then need to hook into the begin request method within your Global.asax.cs file and add a call to ScheduledJobMaintenance.CheckScheduledJobs().

  1: protected void Application_BeginRequest(object sender, EventArgs e)
  2: {
  3:    ScheduledJobMaintenance.CheckScheduledJobs();
  4: }

The ScheduleJobMaintenance class has the following static properties:

  • MaximumJobRunTimeInMinutes – This defines the maximum length of time a job can be in a running state, the default is 60 minutes.
  • CheckTimeInMinutes – This defines the duration in minutes running jobs should be checked, the default is 11 minutes don’t ask me why Smile.

What does it do?

Every time a request is made to the site the CheckScheduledJobs method will be called.  This will then check the last time a check was made, if the duration has gone over the CheckTimeInMinutes then it will do the following:

  • Queue a new thread.
  • Check if there are any jobs in a running state that have gone over the maximum job running time.
  • If there are jobs that have met the previous condition then it will set the next execution time to be in the future, the way this is set is determined by the IntervalType.
  • Update the relevant rows in the tblScheduledItem table to turn them into runnable jobs again.
  • Update the last check time.

For info this currently does not fix jobs that have IntervalType’s of Years or Seconds.

Apr 26, 2012

Comments

Please login to comment.
Latest blogs
Make Global Assets Site- and Language-Aware at Indexing Time

I had a support case the other day with a question around search on global assets on a multisite. This is the result of that investigation. This co...

dada | Jun 26, 2025

The remote server returned an error: (400) Bad Request – when configuring Azure Storage for an older Optimizely CMS site

How to fix a strange issue that occurred when I moved editor-uploaded files for some old Optimizely CMS 11 solutions to Azure Storage.

Tomas Hensrud Gulla | Jun 26, 2025 |

Enable Opal AI for your Optimizely products

Learn how to enable Opal AI, and meet your infinite workforce.

Tomas Hensrud Gulla | Jun 25, 2025 |

Deploying to Optimizely Frontend Hosting: A Practical Guide

Optimizely Frontend Hosting is a cloud-based solution for deploying headless frontend applications - currently supporting only Next.js projects. It...

Szymon Uryga | Jun 25, 2025

World on Opti ID

We're excited to announce that world.optimizely.com is now integrated with Opti ID! What does this mean for you? New Users:  You can now log in wit...

Patrick Lam | Jun 22, 2025

Avoid Scandinavian Letters in File Names in Optimizely CMS

Discover how Scandinavian letters in file names can break media in Optimizely CMS—and learn a simple code fix to automatically sanitize uploads for...

Henning Sjørbotten | Jun 19, 2025 |