How to Schedule an Automatic Reboot in Windows Server 2003/2008 Using Task Scheduler and Command Line


2 views

For Windows Server 2003 and 2008, the Task Scheduler provides the most reliable way to schedule reboots:


1. Open Task Scheduler (Start > Administrative Tools > Task Scheduler)
2. Create a new task:
   - General tab: Name it "Scheduled Reboot"
   - Triggers tab: Set your desired schedule (e.g., daily at 3 AM)
   - Actions tab: Create new action
     - Action: "Start a program"
     - Program/script: "shutdown.exe"
     - Arguments: "/r /f /t 0"
3. Set the task to run with highest privileges

You can create a scheduled task directly from command prompt:


schtasks /create /tn "Nightly Reboot" /tr "shutdown.exe /r /f /t 0" /sc daily /st 03:00

For servers running critical services, consider adding these parameters:


shutdown.exe /r /f /t 300 /c "Server will reboot in 5 minutes for maintenance"

The /t parameter gives users a 300-second (5 minute) warning before reboot occurs.

To list all scheduled tasks on the server:


schtasks /query /fo LIST /v

For Windows Server 2008, PowerShell provides more flexibility:


$Trigger = New-ScheduledTaskTrigger -Daily -At 3am
$Action = New-ScheduledTaskAction -Execute "shutdown.exe" -Argument "/r /f /t 0"
Register-ScheduledTask -TaskName "AutoReboot" -Trigger $Trigger -Action $Action -RunLevel Highest

When scheduling reboots:

  • Ensure all critical services are set to auto-start
  • Consider maintenance windows when applications aren't in heavy use
  • Test on non-production servers first
  • Document the scheduled reboot in your server maintenance log

If the reboot doesn't occur as scheduled:

  1. Check Task Scheduler history for errors
  2. Verify the user account running the task has proper permissions
  3. Ensure the server isn't set to skip scheduled tasks on battery power (even for physical servers)

When maintaining Windows Server 2003 or 2008 systems, scheduled reboots are often necessary for applying updates or clearing memory leaks. The challenge is automating this process during maintenance windows without manual intervention.

The most straightforward approach uses the built-in shutdown.exe utility. Open Command Prompt as Administrator and run:

shutdown /r /t 300 /f /c "Scheduled server reboot in 5 minutes"

This command will:

  • /r - Reboot the computer
  • /t 300 - Set 300-second (5-minute) countdown
  • /f - Force close applications
  • /c - Display custom message

For regular maintenance windows, use Task Scheduler:

schtasks /create /tn "WeeklyReboot" /tr "shutdown /r /f" /sc weekly /d SUN /st 23:00 /ru "System"

Parameters explained:

  • /tn - Task name
  • /tr - Task to run (our shutdown command)
  • /sc - Schedule type (weekly)
  • /d - Day of week
  • /st - Start time
  • /ru - Run as System account

For more control, create a reboot script with logging:

$logPath = "C:\logs\reboot_log.txt"
$rebootTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Add-Content -Path $logPath -Value "Server reboot initiated at $rebootTime"
Start-Sleep -Seconds 300
Stop-Process -Name * -Force -ErrorAction SilentlyContinue
Restart-Computer -Force

If scheduled reboots fail:

  • Verify Task Scheduler service is running
  • Check system permissions (run as SYSTEM or admin)
  • Review Event Viewer logs for errors
  • Test command manually before scheduling

When implementing automated reboots:

  • Set appropriate permissions on scripts
  • Use service accounts instead of personal credentials
  • Notify users in advance through messaging systems
  • Consider maintenance windows when services have lowest usage