We want to restart our Microsoft Internet Information Services (IIS) 5.0 server at scheduled intervals. How do you recommend we do this?

You can use any of several methods to schedule IIS to restart. One common method is to use the IISReset (iisreset.exe) command-line utility with Windows 2000's built-in task scheduler. When you use IISReset without any command-line arguments, the utility will stop and start IIS and all related Internet services (e.g., FTP, SMTP, Network News Transfer Protocol—NNTP) according to the time interval you specify. Open Win2K's Task Scheduler by clicking Start, Settings, Control Panel, Scheduled Tasks. Double-click Add Scheduled Task and click Next. Click Browse, navigate to the \%systemroot%\system32 folder, select iisreset.exe, then click Open. The scheduler will automatically name the task iisreset; you can accept that name or modify it, then assign a daily, weekly, or monthly time interval for running the task. Click Next and complete the time information, if required. You must designate the domain name or username of an administrator account that can run IISReset, then click Finish. When IISReset runs, Event Viewer creates an entry for the event, so you can confirm that the reset occurs.

The IIS 5.0 Process Recycling Tool (IIS5Recycle) also lets you configure an IIS reset at set intervals as well as after a set number of GET requests or when available memory becomes low. You can download IIS5Recycle at http://www.microsoft.com/downloads/release.asp?releaseid=31106.

Keep in mind that resetting IIS can have adverse consequences, such as losing session information and disconnecting users from the IIS server. Also, restarting the server restarts all Web applications, so all variables stored in the application's memory are lost. The restart resets Secure Sockets Layer (SSL) sessions in progress and database connections. Depending on implementation details, the effects of restarting IIS can range from insignificant to unacceptable.

If you run multiple Web applications, stopping and starting the entire IIS server—thereby interrupting service for all Web applications—is annoying, at the least. To mitigate these problems, you can invoke stopweb.vbs and startweb.vbs instead of IISReset. These administrative scripts let you stop and start just one Web site instead of the entire server. The following batch file invokes the correct commands:

C:\inetpub\adminscripts\stop
web.vbs ­a 1

C:\inetpub\adminscripts
\startweb.vbs ­a 1

The above commands stop and start the default Web site (Web site number 1) on default installations of IIS 5.0 or Internet Information Server (IIS) 4.0. The Web site number is a unique number that IIS assigns to the Web site when you create it. If you don't know the Web site number, you can use the findweb.vbs script, which is in the \inetpub\adminscripts folder by default, to retrieve the Web site number for a specified Web site name. For example,

C:\inetpub\adminscripts\find
web.vbs "Default Web Site"

returns the result "Web Site Number =1". Note that the Web site name is case sensitive.

IIS 6.0 has built-in functionality similar to IIS5Recycle. However, in IIS 6.0, you set the parameters to recycle specified Web applications instead of the entire IIS server.