iisazureapplication-pool

Set default app pool recycling via command line


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.


Solution

  • 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']