Configure an Application Pool to Recycle at a Scheduled 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 any specific time in a 24-hour period. Based on what you know about the application, you should set the interval to be frequent enough to prevent application failure.
Prerequisites
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
- None
To configure an application pool to recycle at a scheduled time
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.
User Interface
To use the UI
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 Specific time(s), and in the corresponding box type a time at which you want the application pool to recycle daily. For example, type 11:30 AM or 11:30 PM.
Note
The value that you enter is saved in configuration based on a 24-hour clock.
- Click Next, select the events that should be logged when an application pool recycles and then click Finish.
Command Line
To schedule an application pool to recycle at a specific time, use the following syntax:
**appcmd set apppool /apppool.name:**string /+recycling.periodicRestart.schedule.[value='timeSpan']
The variable string 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 at which to recycle the application pool.
Note
The value that you specify must be based on a 24-hour clock.
For example, to schedule an application pool named Marketing to recycle daily at 3:00 PM, type the following at the command prompt, and then press ENTER:
appcmd set apppool /apppool.name:Marketing /+recycling.periodicRestart.schedule.[value='15:00:00']
To change an existing scheduled time, use the following syntax:
**appcmd set apppool /apppool.name:string /recycling.periodicRestart.schedule.[value='timeSpan'].value: [d].hh:mm:**ss
The variable string is the name of the application pool that you want to configure. The first instance of timeSpan is the existing scheduled time at which the application pool recycles, and the second instance is the new time at which you want the application pool to recycle. The format of timeSpan is d.hh:mm:ss, where d is the optional number of days, and hh:mm:ss is the number of hours, minutes, and seconds at which to recycle the application pool.
Note
The value that you specify must be based on a 24-hour clock.
For example, if you want the Marketing application pool from the previous example to recycle at 5:00 PM, type the following at the command prompt and then press ENTER:
appcmd set apppool /apppool.name:Marketing /recycling.periodicRestart.schedule.[value='15:00:00'].value:17:00:00
For more information about Appcmd.exe, see Appcmd.exe (IIS 7).
Configuration
The procedure in this topic affects the following configuration elements:
<add> element under <schedule> under <periodicRestart>
For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.
WMI
Use the following WMI classes, methods, or properties to perform this procedure:
- ApplicationPool.Recycling.PeriodicRestart.Schedule property
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.
See Also
Concepts
Configuring Recycling Settings for an Application Pool (IIS 7)
Managing Application Pools in IIS 7