Linux(CentOS):開機自動啓動Tomcat腳本(判斷MySQL是否啓動後再啓)

ntpdate cn.pool.ntp.org
SERVER=192.168.127.1
PORT=3306
for num in  {1..300};  do
 </dev/tcp/$SERVER/$PORT
 if [ "$?" -ne 0 ]; then
   echo "Connection to $SERVER on port $PORT failed"
   sleep 20s
 else
   echo "Connection to $SERVER on port $PORT succeeded"
   /home/apache-tomcat-6.0.39/bin/startup.sh &
   break
fi
done

exit
腳本文件名:
start.sh
關鍵字解釋:
ntpdate cn.pool.ntp.org:Linux下同步時間
SERVER=192.168.127.1:MySQL的IP地址
/home/apache-tomcat-6.0.39/bin/startup.sh &:tomcat的bin目錄下startup.sh文件路徑

配置開機自動啓動tomcat:vi /etc/rc.d/rc.local添加以下代碼:/home/apache-tomcat-6.0.39/bin/start.sh &
相關文章
相關標籤/搜索