Click an Ad

If you find this blog helpful, please support me by clicking an ad!

Thursday, March 6, 2014

How to Automate Rebooting a Server

Let's suppose you have an application that acts up. Let's also suppose that instead of fixing the application, you are asked to reboot the server once per week, and that your persuasive arguments fail.

Here's how I automate the rebooting of one of these mythical beasts.

Create a batch file named RebootThisFilthyAppServer.bat, and then put the following in the batch file:

c:\windows\system32\shutdown.exe /r /c "Weekly Reboot Scheduled Task" /f /d p:04:01 /t 90

What the switches mean:
/r - reboot (/h would be a shut down. "halt" is easy to remember)
/c - The comment. In this case, it's "Weekly Reboot Scheduled Task"
/f - force
/d - provide the reason. If you do a shutdown /? at a command line, it lists the reasons. In this case, p:04:01 is "Application: Maintenance (Planned)"
/t - The timeout period before shutting down. This gives your apps a chance to close gracefully in response to the shutdown sequence, before they are forced by the /f

Now, make a scheduled task to run the batch file at the time that you want to rebooot, and you are good to go.


  1. I thought a PowerShell wizard like you would have used Restart-Computer... ;-)

  2. How astute of you! Actually, I did this back in the dark ages when I didn't really know Powershell that well. :)