redhat as 4 下tomcat的autostart(轉)

忙了好長一段時間,網上也有好多的解決方法,但是我試過,一個都不行,至少我不行,最後終於找到一個方法成功的,現在介紹給大家.
If you want Tomcat to start automatically on server start, you can copy the catalina.sh script to your /etc/init.d directory, and with a few modifications incorporate the script into chkconfig.
mv /usr/java/tomcat/bin/catalina.sh /etc/init.d/catalina

Edit /etc/init.d/catalina then immediately following the first comments add:

# chkconfig: - 90 15
# description: Jakarta Tomcat Java Servlets and JSP server
CATALINA_HOME=/usr/java/tomcat
JAVA_HOME=/usr/java/jdkxxx
status() {
ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' | wc | awk '{print $2}' > /tmp/tomcat_process_count.txt
read line < /tmp/tomcat_process_count.txt
if [ $line -gt 0 ] ; then
echo -n "Tomcat ( pid "
ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
echo -n ") is running..."
echo
else
echo "Tomcat is stopped."
fi
}

After the line # ---- Execute the Requested Command ---- enclose the block of echo commands within an if condition:

# ---- Execute the Requested Command ----
if [ "$1" != "status"]; then
echo "Using CATALINA_BASE: $CATALINA_BASE"
echo "Using CATALINA_HOME: $CATALINA_HOME"
echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
if [ "$1" = "debug" -o "$1" = "javac" ] ; then
echo "Using JAVA_HOME: $JAVA_HOME"
else
echo "Using JRE_HOME: $JRE_HOME"
fi
fi

Before the second to last else statement add:

elif [ "$1" = "status" ];then
status
elif [ "$1" = "restart" ];then
$0 stop
$0 start

To add /etc/init.d/catalina to chkconfig use the following commands:

chkconfig --add catalina
chkconfig catalina on
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章