Link to home
Start Free TrialLog in
Avatar of averyb
averybFlag for United States of America

asked on

How to create startup script that can execute certain commands based on if the server had an unexpected reboot

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.

ASKER CERTIFIED SOLUTION
Avatar of tomerlei
tomerlei

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of averyb

ASKER

That sounds like it'll work.

Any reason why I couldn't use the IF EXist to also check another server for a graceful shutdown?
I'd map a drive first.
net use z:\\server2\c$
If Exist z:\unexpected.txt goto unexpected
etc . . .

Thanks again.
Avatar of tomerlei
tomerlei

Ofcourse it will work, this will work either:
IF EXIST \\server2\c$\unexpected.txt goto unexpected
a bit more clean :)
Avatar of averyb

ASKER

I have another related question, but I'll open a new ticket for it.