#cd /etc/init.d
#touch tomcat
2. Copy and paste script on /etc/init.d/tomcat
#!/bin/bash
TOMCAT_HOME=/opt/tomcat/bin
START_TOMCAT=/opt/tomcat/bin/startup.sh
STOP_TOMCAT=/opt/tomcat/bin/shutdown.sh
start() {
echo -n "Starting tomcat8: "
cd $TOMCAT_HOME
${START_TOMCAT}
echo "done."
}
stop() {
echo -n "Shutting down tomcat8: "
cd $TOMCAT_HOME
${STOP_TOMCAT}
echo "done."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
3. Change tomcat file permission
#chmod 755 tomcat
4. Run chkconfig command to add the script to the startup services
#chkconfig tomcat on
5.Verify tomcat service
#service tomcat start
#service tomcat stop
source :
0 comments:
Post a Comment