Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Lee Crowe
Apr 26, 2012
  4268
(4 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

Debasish Banerjee
Debasish Banerjee Apr 27, 2012 09:31 AM

Nice..We had this issue in our project and we created a dashboard to check which schedulers got stuck.But This solution is far better.

Arild Henrichsen
Arild Henrichsen Apr 29, 2012 05:07 PM

Great idea Lee. A tool like this should have been an integrated part of EPiServer admin mode long ago.

Mads Frisk Sørensen
Mads Frisk Sørensen Apr 25, 2019 10:05 AM

Hello.

We have inherited a old solution that uses this fix. They have upgraded to Episerver 8.2 at some point in time. Is this fix still relevant, or was it only for Episerver 6?

Please login to comment.
Latest blogs
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog