Email Notification Before Windows Updates on Server?

5,116

The hanging during reboots is a very well known problem. I suggest changing the way the server does it's updates, especially not allowing it to reboot as part of the updating process. The method I've been using for a number of years with total reliability is:

  • Updates are downloaded by the server (in my case they are obtained from a WSUS server) as they become available but not installed.
  • Saturday night a script runs to install those updates but the server is not rebooted at this stage.
  • Early Sunday morning the server is rebooted using a batch file via the task scheduler. That batch file uses shutdown.exe to perform the reboot. It is first run to log off anyone on the server, then run again to do the actual reboot. Trying to do both at once is very unreliable.

Since implementing that system I've never had a server hang during a reboot. Prior to that at least one of the servers, sometimes more, would hang at few times a year.

In addition to the above I also have a batch file run as a machine startup script which emails me when the server reboots. I check me email first thing Sunday morning. If ever I don't have an email from each of the servers I know I have a problem, because either it didn't start the reboot or it didn't finish it. It doubles as a handy alert should a server ever reboot itself for any reason.

Update:

The install script I use (UpdateHF_v2.5.vbs) was created by Rob Dunn and is available from here. I have customised my copy slightly to suit my own needs.

The reboot batch file is:

@echo off
%windir%\system32\shutdown /l /t 1
%windir%\system32\shutdown /r /t 10 /c "Planned reboot" /f /d P:2:17

The batch file which sends the reboot notification email is (private information removed):

@echo off
c:\windows\blat.exe - -to "list of email addresses, separated with comas" -f "sender email" -s "Reboot Alert (Put the server name here)" -ti 30 -try 120 -noh -body "Whatever message you want" -server mail.server

I use blat but obviously you can use any command line email program you like.

Share:
5,116

Related videos on Youtube

Raleigh Buckner
Author by

Raleigh Buckner

A dynamic and results-driven Information Technology Professional with 15+ years’ experience building high-performance, scalable web-based, and standalone multi-tier applications that solve business problems effectively. Excellent knowledge of requirements gathering, performance tuning, code reviews, test planning, build, deployment, and memory management.

Updated on September 17, 2022

Comments

  • Raleigh Buckner
    Raleigh Buckner almost 2 years

    Can I have my server send an email before it starts the Windows update process?

    Details

    We have a Virtual Private Server running several websites at a hosting company. The server is currently set up to automatically install updates. A couple of times over the last few months, the server has failed to restart after the Windows Update. I would like to be notified when an update is about to be applied so I can check up on the server shortly thereafter.

    Server Info:

    • VPS is running in Microsoft Virtual Server Enterprise Edition (I have no control over the host machine however)
    • Windows Server 2003 Web Edition (32 bit)
  • Raleigh Buckner
    Raleigh Buckner almost 15 years
    could you share the scripts you mentioned? this sounds like a really good method that I think a lot of people could benefit from. Thanks!