java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
配置生效,JDK已经安装完毕。
#!/bin/bash
#
# tomcatd This shell script takes care of starting and stopping
# standalone tomcat
# chkconfig: 345 91 10
# description: tomcat service
# processname: tomcatd
# config file:
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
if [ "${NETWORKING}" = "no" ]; then
echo "Network is stoped! Please open the network!";
exit 0
fi
#执行用户
executor=tomcat
prog=tomcatd
export JAVA_HOME=/usr/local/jdk7/
export CATALINA_HOME=/usr/local/tomcat/
PATH=$PATH:$JAVA_HOME/bin
STARTUP="$CATALINA_HOME/bin/catalina.sh start"
SHUTDOWN="$CATALINA_HOME/bin/catalina.sh stop"
if [ ! -f $CATALINA_HOME/bin/startup.sh ]; then
echo "CATALINA_HOME for tomcatd not available"
exit 0
fi
start() {
# Start daemons.
echo -e $"Startting tomcat service: "
su - $executor -c "$STARTUP"
status
RETVAL=$?
return $RETVAL
}
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 "tomcatd ( pid "
ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
echo ") is running..."
else
echo "Tomcat is stopped"
fi
}
stop() {
# Stop daemons.
echo -e $"Stoping tomcat service:"
su - $executor -c "$SHUTDOWN"
RETVAL=$?
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
sleep 10
start
RETVAL=$?
;;
status)
status
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
View Code