9/9/11

Windows Admin Duties: automate reboot of the server

I needed to come up with a way to reboot the server over night on a one off occasion.

Well I already knew what to do, but I could not remember it so I am documenting this for later.

The following can be executed at the CMD prompt & the syntax below is exact.

at 1:00am cmd /c shutdown -r -t 120 /c "Server will shutdown in 2 min; use shutdown /a in the cmd prompt to stop this action" /f /d p:4:1

This cmd will /f force application shutdown & /c provide an event viewer comment & /d log an event into the event log that is p or planned and reason code 4 (application maintenance) & 1 (planned). Addtionally I am rebooting the server or shutdown -r(reboot) -t(time) 120 (seconds). I cannot run commands directly with at so I must have at load the CMD prompt or cmd & tell the CMD prompt to run a command once loaded /c.

Reason codes: http://ss64.com/nt/shutdown.html
Cmd ref on Tech-net: http://technet.microsoft.com/en-us/library/cc732503%28WS.10%29.aspx