- login to EC2 instance with putty
- sudo su
- cd /etc/init.d
- vim tomcat
- put following into the file #!/bin/bash
- Change permissions. chmod 755 tomcat
- Add script to system services. chkconfig --add tomcat
- Test it out. service tomcat start, service tomcat stop.
# chkconfig: 234 20 80
# description: Tomcat Server basic start/shutdown script
# processname: tomcat
JAVA_HOME=/usr/java/jdk1.6.0_24
export JAVA_HOME
TOMCAT_HOME=/usr/share/apache-tomcat-7.0.23/bin
START_TOMCAT=/usr/share/apache-tomcat-7.0.23/bin/startup.sh
STOP_TOMCAT=/usr/share/apache-tomcat-7.0.23/bin/shutdown.sh
start() { echo -n "Starting tomcat: "
cd $TOMCAT_HOME
${START_TOMCAT}
echo "done." }
stop() { echo -n "Shutting down tomcat: "
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
No comments:
Post a Comment