SaaS CMS has officially launched! Learn more now.

Scheduled Jobs only run when logged into the EPiServer server


We upgraded to CMS12. A couple of weeks ago I had setup the scheduled jobs to run at the proper times and fired them off manually. Then about one week ago I turned the jobs on. The issue is that they will only run when I'm logged into that server via the url. This morning I was checking the jobs for any errors and noticed none of them had run over the weekend and jujst said "Queued". Then one by one, they strated to firing off.

May 20, 2024 13:42

Have you enabled the scheduler in appsettings?

  "EPiServer": {
    "CMS": {
      "Scheduler": {
        "Enabled": true
May 20, 2024 18:59
Eric - May 21, 2024 14:54
We have this one set correctly. If this is false, a message will display in epi that scheduled jobs are turned off. We didn't have that message.

And I think you should check your startup file if you are disable Scheduler programmatically as following:

services.Configure<SchedulerOptions>(options => options.Enabled = false);

Enabled flag is true by default. If you are setting in the code then you should remove this code or set to True explicitly

May 21, 2024 7:40
Eric - May 21, 2024 14:55
I did find in code where we had it set to true in one place and false in another. I'm betting this is the issue. Will find out once we push code to prod.

Do you get this error when you run in your local? Which server that you are using to test? Not DXP? It is on-premise server right? Linux or Windows?

May 21, 2024 14:57
Eric - May 21, 2024 15:03
We are on-promise. In local we set both of these to false so we aren't running jobs all the time we are developing. We don't get any errors; the prod jobs just won't run unless we have EPi opened to the admin.

I guess that your web application could be hibernated through the application pool's idle timeout settings. So the scheduled service is started again when you warm up the application again. So try to check your app pool setting in IIS and change Start Mode to AlwaysRunning

Edited, May 21, 2024 15:20

Hi Eric

If the system is hosted on Windows using IIS, you'll need to ensure IIS pool is configured correctly. By default IIS will shut down the application pool after a period of inactivity as IIS typically does not start background services on its own, it relies on requests that trigger application startup.

As Binh pointed out, can you check your app pool setting Start Mode and change to AlwaysRunning if it is OnDemand?

May 21, 2024 23:44
Eric Herlitz - May 22, 2024 9:02
Even if we are talking about .net core? This seem very strange to me

How do you host this stuff?

  • In DXP? Contact support!
  • In Azure? Check the box in the screenshot below, or get more visitors! 

Edited, May 22, 2024 13:52
Eric - May 22, 2024 13:55
Tomas Hensrud Gulla - May 22, 2024 14:04
So, scheduled jobs will only run when the site is accessed/visited.

If your local URL is not visited, the jobs will not run...
Eric - May 22, 2024 14:08
We are running EPiServer Admin in its own app pool with its own url. The only time the jobs run is when I physically have the admin site up. We still need to apply AlawayRunning to see if that fixes it during a downtime.

I think YES. Need to apply AlwaysRunning to fix it in IIS in local or on-premise.

Just check this code

May 22, 2024 14:25

It appears as if .net core+ will benefit from some IIS settings, this was answered in this SO-thread. Keep ASP.NET core app running all the time in IIS - Stack Overflow

  1. Install Application Initialization Module (IIS) 
  2. IIS > Your App Pool > Start Mode > Always Running
  3. IIS > Your App Pool > Idle Time-out > 0
  4. IIS > Your App > Advanced Settings > Preload Enabled > True
  5. Setup your app for In-Process hosting model (web.config changes for core module and code changes to set correct current directory)
May 22, 2024 18:50
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.