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 &