Cloudkul Support

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.

#!/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

start() {
 bash /opt/tomcat/bin/startup.sh
}

stop() {
 bash /opt/tomcat/bin/shutdown.sh
}

case $1 in
  start|stop) $1;;
  restart) stop; start;;
  *) echo "Run as $0 <start|stop|restart>"; exit 1;;
esac

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.

Is this article is helpful?

People like and 1 people dislike.

If result is not found or irrelevant, Please contact us.

Submit your request

Start a Project






    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home