服务配置文件 tomcat
cp tomcat /etc/init.d/
chmod +x /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on
配置文件tomcat内容:
#!/bin/bash
#
# Startup script for the tomcat
#
# chkconfig: 345 80 15
# description: Tomcat is a Servlet+JSP Engine.
# Source function library.
. /etc/rc.d/init.d/functions
checkjava(){
if [ -z "$JAVA_HOME" ]; then
export JAVA_HOME=/usr/local/jdk1.6.0_20
fi
}
start(){
checkjava
if [ -z $(/sbin/pidof java) ]; then
echo "Starting tomcat"
/usr/local/tomcat/bin/startup.sh
touch /var/lock/subsys/tomcat
else
echo "tomcat allready running"
fi
}
stop(){
checkjava
if [ ! -z $(/sbin/pidof java) ]; then
echo "Shutting down tomcat"
/usr/local/tomcat/bin/shutdown.sh
until [ -z $(/sbin/pidof java) ]; do :; done
rm -f /var/lock/subsys/tomcat
else
echo "tomcat not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
/usr/local/tomcat/bin/catalina.sh version
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac