兩應用程序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端口。