17

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

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

4 Answers 4

16

Make a scheduled task that runs:

shutdown -r -t 01
4
  • Can the scheduled task delete itself when the task is done?
    – Toro
    Apr 30, 2009 at 21:25
  • Can't delete itself, but you can setup a one-time trigger so it'll only run once. Apr 30, 2009 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. Apr 30, 2009 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.)
    – user2874
    Sep 22, 2009 at 14:52
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.

1
  • 2
    Apparently this has been deprecated in Server 2012 Feb 16, 2013 at 8:14
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.

2
  • 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, 2015 at 7: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 5, 2015 at 7: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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .