-1

Is there a way I can automate the restart of the Microsoft SQL services? How do I automate the restart of a Windows server?

1
  • is this because reboots fix everything? re-starting sql server is not a good thing to do, since you loose all the data cached in memory, which is what helps performance Oct 14, 2009 at 7:42

3 Answers 3

4

For SQL Server (or in fact any Windows service) you can use the net stop <Service Name> and net start <Service Name> to stop/start the service.

The service name you must use is not the display name, it's the actual name. To get that, go to the services control panel and view the service properties. It is the highlighted section on the screenshot: alt text

For Windows itself the shutdown command works well. Can be run with the following switches (these are the common ones, there is a few more):

  • /r switch to reboot
  • /s to just shutdown
  • /g reboot and restart registered applications
  • /p for immediate effect - same as using /t 0
  • /f to force running applications to close
  • /m \\computername to be run from another machine.

Aside: I do worry why you want to reboot SQL/Windows on a regular basis - normally that should not be needed and this sounds like a hack for a more serious issue. If you are planning on doing this, please document it fully in your logs and even put comments in the batch file and maybe even a text file as to why. The reasoning for situations like this tend to be forgotten and in the future you may not need to do this - but will have forgotten why you are.

2

You could use shutdown /r /t 0 /c "Scheduled Reboot" /m \\computername from another Domain-Server. Or leave out the /m \\computername and let it run as a scheduled job on the server itself.

0

I'm using PowerOff. You can configure it to run as a service and to show a warning message if case a user is logged on.

You must log in to answer this question.