Configure/Add Tomcat to Startup/Boot list in Linux

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

1. “/etc/init.d/” contains all the startup services in Linux, so the first step is to create a “tomcat” file in “/etc/init.d/”
And add the following code to the file. Remember to adjust RUN_AS_USER and CATALINA_HOME to your environment.

#!/bin/bash
#
# Init file for SixSigns Tomcat server
#
# chkconfig: 2345 55 25
# description: SixSigns Tomcat server
#</code>

# Source function library.
. /etc/init.d/functions

RUN_AS_USER=root # Adjust run user here
CATALINA_HOME=/usr/local/apache-tomcat-6.0.35/ #Adjust here for different location

start() {
echo "Starting Razuna Tomcat: "
if [ "x$USER" != "x$RUN_AS_USER" ]; then
su - $RUN_AS_USER -c "$CATALINA_HOME/bin/startup.sh"
else
$CATALINA_HOME/bin/startup.sh
fi
echo "done."
}
stop() {
echo "Shutting down Razuna Tomcat: "
if [ "x$USER" != "x$RUN_AS_USER" ]; then
su - $RUN_AS_USER -c "$CATALINA_HOME/bin/shutdown.sh"
else
$CATALINA_HOME/bin/shutdown.sh
fi
echo "done."
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
#echo "Hard killing any remaining threads.."
#kill -9 `cat $CATALINA_HOME/work/catalina.pid`
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac

exit 0

2. Save the file
3. Add tomcat to the startup list

chkconfig --add tomcat
chkconfig --level 345 tomcat on

4.To check and confirm if tomcat has been added using:

chkconfig --list

Simple! That’s it. You can also use command to delete service from startup list using:

chkconfig --del

One thought on “Configure/Add Tomcat to Startup/Boot list in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *