How to create a tomcat server upstart script ?
Suppose my tomcat working directory is /opt/tomcat. To start the tomcat service I need to go to the /opt/tomcat/bin directory and run the startup.sh script and for shutdown, I need to run shutdown.sh script. To run the tomcat service through service command I need to create a upstart script.
create a new file /etc/init.d/tomcat and copy the following contents.
case $1 in
restart) stop; start;;
*) echo "Run as $0 <start|stop|restart>"; exit 1;;
After saving the file make it executable and make it available at boot time.
chmod 755 /etc/init.d/tomcat
update-rc.d tomcat defaults
Now, you can use “service tomcat (start|stop|restart)” command for managing tomcat service.