4

I'm trying to execute the following command at the start of an Azure web role to set a specific time in which the app pool will be recycled:

%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.recycling.periodicRestart.schedule.[value='00:08:00']

But when I to do this I get the error:

ERROR ( messsage:Cannot find requested collection element. )

Anyone know how to use appcmd to set default application pool settings to make it recycle at 8:00 AM UTC? Note that the collection of specific times the app pool recycles is empty initially.

Nick Olsen
  • 6,299
  • 11
  • 53
  • 75
  • You might find the following useful: http://blog.smarx.com/posts/controlling-application-pool-idle-timeouts-in-windows-azure – Peter Ritchie Mar 18 '14 at 20:26
  • @PeterRitchie Unfortunately that isn't helpful. That is talking about turning off the idleTimeout or setting it to a value. I am looking for the periodic recycling of the app pool. – Nick Olsen Mar 18 '14 at 21:09

2 Answers2

4

I restart application pools after periods of time, not at certain times of the day. Although your attempt suggests you are kind of doing the same? But that would suggest you are attempting to restart the app pool every 8 minutes? Anyway This is what I use:

appcmd set apppool /apppool.name: string /recycling.periodicRestart.time: ' timeSpan '

Where string is the application pool name and timeSpan is d.hh:mm:ss.

Working Example to restart the defaultapplicationpool every 30 minutes in IIS7:

appcmd set apppool /apppool.name: defaultapplicationpool /recycling.periodicRestart.time: 00:30:00

EDIT

In light of your comment can you not just do this?

appcmd set apppool /apppool.name: string /+recycling.periodicRestart.schedule.[value=' timeSpan ']

EDIT 2

Example of Default App Pool to recycle daily at 00:08am

appcmd set apppool /apppool.name: DefaultAppPool /+recycling.periodicRestart.schedule.[value='00:08:00']
medina
  • 766
  • 1
  • 11
  • 31
  • Unfortunately this doesn't help. As mentioned in the question, I asked for recycling the app pool at a specific time of day. So command I wrote really should be restarting the app pool at 12:08 AM every morning. – Nick Olsen Mar 19 '14 at 13:25
  • @NickOlsen In light of your comment I have edited my original answer. – medina Mar 19 '14 at 13:31
  • That is close to what I have. And what I posted was returning an error. Did you actually try that? What about setting the default application pool settings? – Nick Olsen Mar 19 '14 at 13:39
  • @NickOlsen yes I have tried both above examples and it works as expected. – medina Mar 19 '14 at 13:54
  • What about doing your schedule command for the default app pool settings? – Nick Olsen Mar 19 '14 at 13:58
  • @NickOlsen I have edited my answer with what you need for your example. This is only correct if the default app pool is indeed called 'DefaultAppPool' – medina Mar 19 '14 at 14:11
  • Is there not something you can do using "-section:applicationPools -applicationPoolDefaults"? – Nick Olsen Mar 19 '14 at 14:55
0

I was able to configure it with applicationPoolDefaults like this:

appcmd set config -section:system.applicationHost/applicationPools "/+applicationPoolDefaults.recycling.periodicRestart.schedule.[@0,value='08:00:00']" /commit:apphost
Rémi
  • 889
  • 1
  • 8
  • 12