A project is in a new building, sometimes a power outage, and the temporary UPS can only spare 25-30 minutes and no management functions, before the arrival of the new ups, you need to rely on the following script to prevent loss of data lost power.
Of course, many ups do not have the COM port connection server Auto Power off function, this kind of UPS battery ran out or will cause the server off. You can also use this method to automatically shut down after a power outage.
The principle is simple, in the system to configure a scheduled task every 5 minutes, scheduled tasks to run the batch ping specified IP address, in order to avoid the wrong shutdown recommended at least 2 IP to detect, because after the power outage this IP can not ping (generally use the gateway, switch IP), shut down the host.
In this project, the scheduled task is configured on a 2008r2 Chinese version of the server, while the 3 switches of the ip:192.168.0.37, 192.168.0.38, 192.168.0.39 detection, when they can not ping, wait 10 minutes after the shutdown, Cancel shutdown if power is restored within 10 minutes!
Note: This method is not available for environments without UPS! Because different operating system return values may vary, batches may need to be modified to execute correctly. A little modification can also be implemented to turn off other services at the same time!
@echo offping/n 2/l 1 192.168.0.37|findstr "byte =1" && (goto OK) | | (ping/n 2/l 1 192.168.0.38|findstr "byte =1" && (goto OK) | | (ping/n 2/l 1 192.168.0.39|findstr "byte =1" && goto OK | | goto NG)): O kshutdown/aexit:ngshutdown/f/s/t 600exit
This article is from the "Le TripAdvisor" blog, please make sure to keep this source http://10811686.blog.51cto.com/10801686/1704222
Automatic shutdown batch after server power off for WINDOWS