How to create startup script that can execute certain commands based on if the server had an unexpected reboot
Posted on 2006-06-07
I have two Windows 2003 servers and 3rd Linux based device.
If Server 1 crashed and rebooted it would need to reboot the Linux device, wait about a minutes, and then start a bunch of services on Server1.
If Server 2 crashed or rebooted unexpectedly it would need to stop services on Server 1 wait 30 seconds and then restart the services. If it were rebooted gracefully, then none of this would need to happen.
I can do the commands using regular bat files, but I don't know how to determine if a reboot was unexpected or not.
If needed I expect I can have make it work.
Startup script does all the commands mentioned above
Shutdown script renames the startup script to something else and replaces it with a "safe" startup script.
The Safe startup script would rename the startup script back to what it should be.
I'd like to have something more elegant and not as complex.
Be warned, my scripting experience is limited to bat files issuing standard windows commands like netsvc or the like. Be prepared for some very basic questions.