December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Tomcat stop start script for redhat

#Startup script for Tomcat
JAVA_HOME=/usr/java/jdk1.6.0_43
export JAVA_HOME
start_tomcat=/opt/tomcat6/bin/startup.sh
stop_tomcat=/opt/tomcat6/bin/shutdown.sh

start() {
echo -n “Starting tomcat:”
su -c ${start_tomcat} – tomcat
echo “done.”
}
stop() {
echo -n “Shutting down tomcat: “
${stop_tomcat}
echo “done.”
}

# See how we were called
case “$1” in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo “Usage: $0 {start|stop|restart}”
esac
exit 0

#Startup script for Tomcat
# description: Start tomcat
# chkconfig: 345 99 01
JAVA_HOME=/usr/java/jdk1.6.0_43
export JAVA_HOME
start_tomcat=/opt/tomcat6/bin/startup.sh
stop_tomcat=/opt/tomcat6/bin/shutdown.sh

NAME=”$(basename $0)”
unset ISBOOT
if [ “${NAME:0:1}” = “S” -o “${NAME:0:1}” = “K” ]; then
NAME=”${NAME:3}”
ISBOOT=”1″
fi

# Define the tomcat username
TOMCAT_USER=”${TOMCAT_USER:-tomcat}”

start() {
echo -n “Starting tomcat:”
su -c ${start_tomcat} – tomcat
echo “done.”
}
stop() {
echo -n “Shutting down tomcat: “
${stop_tomcat}
echo “done.”
}

# See how we were called
case “$1” in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
status)
if [ -f “/var/run/${NAME}.pid” ]; then
read kpid < /var/run/${NAME}.pid
if [ -d “/proc/${kpid}” ]; then
echo “${NAME} (pid ${kpid}) is running…”
RETVAL=”0″
fi
else
pid=”$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} java)”
if [ -z “$pid” ]; then
echo “${NAME} is stopped”
RETVAL=”3″
else
echo “${NAME} (pid $pid) is running…”
RETVAL=”0″
fi
fi
;;
*)
echo “Usage: $0 {start|stop|restart}”
esac
exit 0

#Startup script for Tomcat
# description: Start tomcat
# chkconfig: 345 99 01
JAVA_HOME=/usr/java/jdk1.6.0_43
export JAVA_HOME
start_tomcat=/opt/tomcat6/bin/startup.sh
stop_tomcat=/opt/tomcat6/bin/shutdown.sh

NAME=”$(basename $0)”
unset ISBOOT
if [ “${NAME:0:1}” = “S” -o “${NAME:0:1}” = “K” ]; then
NAME=”${NAME:3}”
ISBOOT=”1″
fi

# Define the tomcat username
TOMCAT_USER=”${TOMCAT_USER:-tomcat}”

start() {
echo -n “Starting tomcat:”
su -c ${start_tomcat} – tomcat
echo “done.”
}
stop() {
echo -n “Shutting down tomcat: ”
${stop_tomcat}
echo “done.”
}

# See how we were called
case “$1” in
start)
if [ -f “/var/run/${NAME}.pid” ]; then
read kpid < /var/run/${NAME}.pid if [ -d "/proc/${kpid}" ]; then echo "Error: ${NAME} (pid ${kpid}) is already running..." RETVAL="0" fi else pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} java)" if [ -z "$pid" ]; then start RETVAL="3" else echo "Error: ${NAME} (pid $pid) is already running..." RETVAL="0" fi fi ;; stop) stop ;; restart) stop sleep 10 start ;; status) if [ -f "/var/run/${NAME}.pid" ]; then read kpid < /var/run/${NAME}.pid if [ -d "/proc/${kpid}" ]; then echo "${NAME} (pid ${kpid}) is running..." RETVAL="0" fi else pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} java)" if [ -z "$pid" ]; then echo "${NAME} is stopped" RETVAL="3" else echo "${NAME} (pid $pid) is running..." RETVAL="0" fi fi ;; *) echo "Usage: $0 {start|stop|restart|status}" esac exit 0

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>