Configure an Application Pool to Recycle after an Elapsed Time (IIS 7)
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
If you have an application that causes problems when it runs for an extended time, you can configure the application pool to recycle at a specific interval (set in minutes). Based on what you know about the application, you should set the value to be less than the length of time elapsed before application failure.
For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see Application Pools Feature Requirements (IIS 7).
Exceptions to Feature Requirements
You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
In the Connections pane, expand the server node and click Application Pools.
On the Application Pools page, select an application pool, and then click Recycling in the Actions pane.
Select Regular time intervals (in minutes), and in the corresponding box type a time interval (in minutes) at which you want the application pool to recycle.
Click Next, select the events that should be logged when an application pool recycles, and then click Finish.
To configure an application pool to recycle at regular time intervals, use the following syntax:
appcmd set apppool /apppool.name: string /recycling.periodicRestart.time: ' timeSpan ']
The variable name is the name of the application pool that you want to configure. The variable timeSpan is in the format d.hh:mm:ss, where d is the optional number of days, and hh:mm:ss is the number of hours, minutes, and seconds after which to recycle the application pool. For example, to configure an application pool named Marketing to recycle every thirty minutes, type the following at the command prompt, and then press ENTER:
appcmd set apppool /apppool.name: Marketing /recycling.periodicRestart.time:00:30:00
For more information about Appcmd.exe, see Appcmd.exe (IIS 7).
The procedure in this topic affects the following configuration elements:
time attribute of the <periodicRestart> element under <recycling>
For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.
Use the following WMI classes, methods, or properties to perform this procedure:
For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.