Tuesday, March 19, 2013
Windows scheduled reboot
This is a command I use a lot. Many times I'll need to have a server reboot later at night, and then I forget to actually reboot it. I could set a reminder on my phone but why do that when there are tools to do it for you.
Run this from a command line with the time and date you want the machine to reboot.
schtasks /create /tn "Reboot" /tr "shutdown /r /t 1" /sc once /st 22:00:00 /sd 03/05/2013 /ru "System" /z
schtasks is the command line software for scheduling tasks. This is needed when you are trying to run something as System since you can't set that from the GUI.
More info here -> http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx?mfr=true
/create - creates the task.
/tn - the name of the task.
/tr - the command
/sc - the frequency, here I use "once" since I don't want a nightly reboot.
/st - the time for the command to run
/sd - the date for the command to run.
/ru - the user to run as, in this case System.
/z - delete the scheduled task once it has run. This only works on certain OS's.
For the shutdown command....
/r - reboot
/t - how many seconds to wait, in this case, 1.