IIS 7 and Above
IIS Application Pools
Last post Feb 06, 2013 10:21 PM by fredcumbee
Feb 06, 2013 09:16 PM|hikaru1207|LINK
Is there any way to recycle the specific Application Pools in my IIS? I'm using ASP.NET and I want to recycle the pool when it crush. Thus it possible?
Feb 06, 2013 10:21 PM|fredcumbee|LINK
If you're looking for an automated way in IIS to recycle an application pool when it crashes then nothing like that exists in IIS. There are recycling options on an app pool that will allow the app pool to reycle at a certain time interval, recycle after
a fix amount of requests, or recycle when the private or virtual memory usage gets to a certain amount.
There is a way you can automate recycling the app pool but this is more of a band aide than a solution. You should look into why the app pool is crashing and try and resolve the issue. If the app pool is crashing then it should be generating a consistent
error in the event logs. Find out what the Event ID for the error. Create a script that recycles the app pool. You can create a batch file and add the command below. Just update it with your app pool name.
To recycle an application pool, use the following syntax:
appcmd recycle apppool /apppool.name:string
The variable string is the name of the application pool that you want to recycle. For example, to recycle an application pool named
Marketing, type the following at the command prompt, and then press ENTER:
appcmd recycle apppool /apppool.name:Marketing
Once you have created the batch file with the recycle command, save the script on the server. Now all you need to do is create a schedule task that is triggered "When a specific event is logged" and have it run the script. Select the Application or System
event log where the Event ID is logged, along with the Source and Event ID number in the schedule task. Make sure the task is set to "Run whether the user is logged on or not". Also, instead of call a the script you could have the scheduled task run appcmd.exe
and specify the arguments recycle apppool /apppool.name:string.