Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recycle app pool on a specific time during work days?

Tags:

asp.net

iis

Is it possible to schedule an App Pool recycle on a specific time only during work days?

Thanks in advance!

like image 412
adamfinstorp Avatar asked Feb 28 '12 15:02

adamfinstorp


2 Answers

In case you can't configure the desired schedule using IIS directly, you could create a scheduled task that invokes

c:\Windows\system32\inetsrv\appcmd.exe recycle apppool "NameOfTheAppPool"

at the required times.

like image 118
Andre Loker Avatar answered Oct 03 '22 16:10

Andre Loker


If you are using IIS 7, PeriodicRestart is the key. Add the following into your ApplicationHost.config file:

<add name="YourApplicationPool">
   <recycling logEventOnRecycle="Schedule">
      <periodicRestart>
         <schedule>
            <clear />
            <add value="12:00:00" />
         </schedule>
      </periodicRestart>
   </recycling>
   <processModel identityType="NetworkService" shutdownTimeLimit="00:00:30" startupTimeLimit="00:00:30" />
</add>

It will recycle your Application Pool at 12 o'clock each day.

If you are using IIS7, you could setup a Scheduled Task, for the work days, running the following command:

appcmd.exe recycle apppool "YourApplicationPool"

If you are using IIS6, I'd follow the guide here.

like image 42
Neil Knight Avatar answered Oct 03 '22 15:10

Neil Knight