Sysadmins of the North
Don't forget to share this post!

Set IIS Application Pool recycle defaults to Specific Times, not Regular Time Interval

By default, an IIS application pool (or “AppPool”) recycles on a regular time interval of 1740 minutes, or 29 hours. One reason for this time interval is that application pools don’t recycle at the same moment every day (every day at 07.00 for example). However, sometimes you want to change this regular time interval to specific times. And when you try to configure this in IIS Manager, it gives you an error. Luckily, AppCmd and PowerShell come to the rescue!

IIS Application Pool recycling defaults

Recycling means the worker process that handles requests for an application pool is terminated and a new worker process is started.

Why is IIS’ default application pool recycling set to 1740 minutes? One reason for this time interval is that application pools don’t recycle at the same moment every day, and 29 hours for the simple reason that it’s the smallest prime number over 24. A staggered and non-repeating pattern that doesn’t occur more frequently than once per day, “you don’t get a resonate pattern” (Source: Scott Forsyth’s Blog).

Imagine your IIS application pool (AppPools) are configured to recycle on a regular time interval of 1740 minutes, and you want to change this setting through Internet Information Services (IIS) Manager to a time interval. You either browse to an application pool and its Advanced Settings, or you try to set Application Pool Defaults.

This may interest you:   IIS URL Rewrite "Rewrite Module error: Expression contains a repeat expression"

When you set the Regular Time Interval (minutes) to 0, an error message pops up:

AppPool IdleTime-out property error
AppPool IdleTime-out property error

The ‘Idle Time-out (minutes)’ property of the application pool’s process model must be less than the Regular Time Interval (minutes)’ property of the application pool’s period restart.

Setting the AppPool Idle Time-out property to zero (0) -because you want to set the Regular Time Interval to 0- may result in unwanted AppPool and website behavior… This is a known bug in the IIS Manager GUI.

Appcmd to configure application pool recycle on Specific Times and set Regular Time Interval to 0

Configure a periodicRestart

Fortunately you can use AppCmd to configure these Regular Time Interval and Specific Times Application Pool Defaults settings. First you have to set the Regular Time Interval to 0:

AppCmd set config

Next, you’ll configure a Periodic Restart Schedule (4 A.M):

AppCmd set config

The @0 numeric index is used so more than one periodic restart schedules can be created (not sure this is necessary). This makes all application pools to recycle at 4 A.M in the morning, suppose you would want this.

In PowerShell, set application pool Specific Times TimeSpan value

If you want to use a more PowerShell solution to set an application pool to recycle on a specific time (in stead of a regular interval), you can use the following PS snippets:

Set-WebConfiguration `
  /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart `
  -value "0"

And then you add a specific time for the application pool to recycle on (note the add-, not set-):

Add-WebConfiguration ` 
  /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart/schedule `
  -value (New-TimeSpan -h 4 -m 00)

Verify your newly made settings:

Get-WebConfiguration `
  /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart/schedule/add ` 
  | select value

Get the Specific Times recycle value of a specific Applicaton Pool using PowerShell’s Get-ItemProperty

If you have set one or more specific times recycle values for an application pool, use the following PowerShell command to get the values:

(Get-ItemProperty ('IIS:\AppPools\') -Name Recycling.periodicRestart.schedule.collection) | select value

The output is for example set to every 6 hours on the hour, starting at midnight:


Get recycling.periodicRestart.schedule using appcmd:

appcmd.exe list apppool /config

The appcmd command above will list the current application pool ‘’ configuration, including its scheduled periodicRestart. Substitute /config with /text:* for all configuration settings for that pool.

This may interest you:   Monitor Windows services with PowerShell

And the IIS Manager GUI?

After setting the regular time interval to 0, you may use the IIS Manager GUI to configure Application Pool Defaults and a Periodic Restart schedule.

Reset Application Pool recycling Defaults back to periodicRestart

If you want to reset your application pool recycling defaults back to periodicRestart (Regular Time Interval), you can do so with the following appcmd command:

# Set applicationPoolDefaults.recycling.periodicRestart.time
# to 29 hours, 1 minute, or 1741 minutes
AppCmd set config -section:system.applicationHost/applicationPools /applicationPoolDefaults.recycling.periodicRestart.time:"29:01:00" /commit:apphost
# Set applicationPoolDefaults.recycling.periodicRestart.time
# to 29 hours, or 1740 minutes
AppCmd set config -section:system.applicationHost/applicationPools /applicationPoolDefaults.recycling.periodicRestart.time:"29:00:00" /commit:apphost

Note: If the Regular Time Interval default is set to 41760 minutes / 29 days, you must reset this to a non-default value. For example 1741. When that’s saved to applicationHost.config, you can reset it back to it’s original regular time interval of 1740 minutes.

buy me a coffee
Buy Me A Coffee

About the Author Jan Reilink

My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, WordPress, websites & optimization. Want to support me and donate? Use this link:

follow me on:

Leave a Comment:

Skip to content