How to automatically restart Tomcat7 on system reboots?
- by coding crow
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
The tomcat7 already has script in it, where do we have to paste the suggested script?
Is the suggested procedure correct?