17

How to schedule a Windows server to reboot at a specified time?

It's about a Windows Server 2003 and Windows Server 2008.

squillman
  • 37,618
  • 10
  • 90
  • 145
Toro
  • 766
  • 3
  • 22
  • 30

4 Answers4

18

The easiest way to schedule a simple reboot is to use the AT command along with the shutdown command from the command line.

For example, if you want the server to restart tonight at 2AM, it can be as simple as this:

at 2:00 shutdown /r /f

What the "AT" command does is automatically create a scheduled task for a certain command. It has a ton of parameters that you can specify to repeat it, but by default it'll just run whatever command you specify at the next instance of whatever time you specify.

If you need to change anything after you issue it, you can just go into Administrative Tools > Scheduled Tasks and modify the task.

Matias Nino
  • 1,372
  • 7
  • 25
  • 40
16

Make a scheduled task that runs:

shutdown -r -t 01
Mark S. Rasmussen
  • 2,108
  • 2
  • 21
  • 31
  • Can the scheduled task delete itself when the task is done? – Toro Apr 30 '09 at 21:25
  • Can't delete itself, but you can setup a one-time trigger so it'll only run once. – Mark S. Rasmussen Apr 30 '09 at 21:28
  • 2
    If the task is scheduled to run once, there is a "delete this task if it is not scheduled to run again" checkbox under the Settings tab of the scheduled task properties window. The scheduler will remove the task after it has run if not scheduled again. Not sure how that will work in the case of a server reboot, though it is theoretically possible. – Justin Scott Apr 30 '09 at 21:43
  • Or, if it is a one-time affair, use the /t xxx to set the shutdown to the desired future time. The delay value can be up to 10 years. (But since it is expressed in seconds, having a very long delay calls for a bit of calculus.) –  Sep 22 '09 at 14:52
4

I know this doesn't solve your whole problem but for versions of Windows Server since 2008, and in cases where you only need the server to reboot once, you don't need to bother with scheduled tasks. The built in shutdown command lets you specify a delay in seconds using the the -t parameter.

Eg, to restart in 12 hrs (or 43200 seconds):

shutdown -r -t 43200

Obviously to get a specific time you'll need some simple maths but it's a lot easier than messing around with scheduled tasks.

Molomby
  • 232
  • 1
  • 7
  • 1
    Is it possible (without script logging or similar) to get the state of such a command after it has been issued? That the time remaining until reboot is 3hrs, for instance? – ErikE Jul 29 '15 at 07:46
  • 1
    @ErikE, The only way I know if is to issue to `shutdown -a` command which aborts the current shutdown. If no shutdown was scheduled, you'll get an error instead. I don't think it tells you *when* it was scheduled for though, and if you actually did want a shutdown you'll need to recreate it... so not ideal. – Molomby Aug 05 '15 at 07:23
0

Try this guide (XP centric but should get you in the right direction)

http://www.electronics.dit.ie/techsupport/Green/How%20to%20schedule%20windows%20XP%20to%20shutdown.doc

Chris Ballance
  • 304
  • 1
  • 7
  • 20