The BAT (batch file) batch is a good thing, the computer Stone age of the weapon, today is still not outdated, the work of accumulating some commonly used batch processing command is still very useful, today to share a practical development used.
Scene:
You need to start multiple Tomcat services under Windows, and you need the first service to start successfully before you can start a second, third service.
Workaround:
The first service judge whether to start successfully, need to read Tomcat Starup.bat output content, to judge to identify, more cumbersome, simplified processing method, is the second, the third service start can be set with the first time interval, such as 2分钟120秒.
Batch Code:
First service startup script Startup1.bat
@echo off Echo "I am the first Tomcat service and everyone relies on me, so I need to start first"
A second service startup script Startup2.bat
@echo off Echo "I am the second Tomcat service and I need the first Tomcat service to start before starting"
A third service startup script Startup3.bat
@echo off Echo "I am the third Tomcat service and I need the first Tomcat service to start before starting"
Start a script for three services in turn Startupall.bat
%cd% represents the current directory, the demo is to put 4 bat files in the same folder, the actual scene, to be replaced with the actual path of the Startup file.
@echo off Echo start the first service Start "" "%cd%\startup1.bat"echo127.0>nulEcho start the second service start "" "%cd%\startup2.bat"Echo launches third service start ""%cd%\startup3.bat "Echo "All services start to complete, automatically shut down after 5seconds" 5 127.0>nulexit
If you think it's useful, please have a 3q!.
[BAT] bat sequence executes other BAT batch files to set the time interval (actual scenario Windows starts with multiple Tomcat services in turn)