How to automatically restart Tomcat7 on system reboots?

Posted by coding crow on Ask Ubuntu See other posts from Ask Ubuntu or by coding crow
Published on 2012-11-24T14:14:19Z Indexed on 2012/12/01 23:20 UTC
Read the original article Hit count: 218

Filed under:
|
|

I have installed Tomcat 7 on Ubuntu 12.04 LTS which run on an Amzon EC2 instance. Now I wish tomcat should restart automatically on system reboot. I read this blog which suggest adding below script to /etc/init.d/tomcat7

# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

case $1 in
start)
sh /usr/share/tomcat7/bin/startup.sh
;;
stop) 
sh /usr/share/tomcat7/bin/shutdown.sh
;;
restart)
sh /usr/share/tomcat7/bin/shutdown.sh
sh /usr/share/tomcat7/bin/startup.sh
;;
esac 
exit 0

and issue the following commands

sudo chmod 755 /etc/init.d/tomcat7

sudo ln -s /etc/init.d/tomcat7 /etc/rc1.d/K99tomcat

sudo ln -s /etc/init.d/tomcat7 /etc/rc2.d/S99tomcat

sudo /etc/init.d/tomcat7 restart

My Questions

  1. The tomcat7 already has script in it, where do we have to paste the suggested script?
  2. Is the suggested procedure correct?

© Ask Ubuntu or respective owner

Related posts about tomcat

Related posts about amazon-ec2