Script to Restart SharePoint Services
Since my previous post introduced one of my SharePoint Toolbox scripts, I thought I should share another one that is more applicable to a broader audience.
As I've noted in the past, memory leaks are certainly not uncommon in the world of SharePoint. Consequently, you may want to periodically simulate a reboot of your development environment in order to free up memory and get back to being productive. Trust me, simulating a reboot is much, much faster than actually rebooting.
To do this, I created the following script and dropped it in my SharePoint Toolbox folder (\NotBackedUp\Public\Toolbox\SharePoint\Scripts\Restart SharePoint Services.cmd):
@echo off
@echo Stopping services...
iisreset /stop /noforce
net stop "Windows SharePoint Services Timer"
net stop "Windows SharePoint Services Administration"
net stop "Office SharePoint Server Search"
net stop "Windows SharePoint Services Search"
net stop "Windows SharePoint Services Tracing"
@pause
@echo Starting services...
net start "Windows SharePoint Services Tracing"
net start "Windows SharePoint Services Search"
net start "Office SharePoint Server Search"
net start "Windows SharePoint Services Administration"
net start "Windows SharePoint Services Timer"
iisreset /start
@pause
Note that I use a pause
statement so that I can optionally perform other tasks while SharePoint is stopped (e.g. detach a content database, move it to a different disk, and then reattach it).
Comments
Anonymous
June 16, 2009
PingBack from http://fixmycrediteasily.info/story.php?id=10350Anonymous
January 22, 2010
The comment has been removedAnonymous
March 10, 2010
@John Thompson: Good tip, thanks. By the way, if you set environment variables like this in a script, I highly recommend adding "setlocal" after the "@echo off" statement at the top of the file. That way you don't need to worry about having the environment variables defined after the script finishes executing.