两应用程序service1和service2,service2依赖service1,即得等service1启动后才能启动,若service1应用占用一确定的tcp端口,如下脚本可实现该操作:
echo “service1 start…”
./service1.sh
netstat -tlnp|grep 2098
until [ “$?” -eq “0” ]
do
echo “waiting service1 to startup…”
sleep 1
netstat -tlnp|grep 2098
done
echo “service1 started.”
./service2.sh
echo “service2 started.”
其中2098为service1占用的tcp端口。