Environment : Ubuntu 14.04 LTS

Prerequisites: Java and Tomcat installed in your machine/instance. JAVA_HOME should be set already before start.

Step 1: Create a file called “tomcat” under /etc/init.d folder and have the contents as below.

# tomcat
# chkconfig:
# description:  Start up the Tomcat servlet engine.

# Source function library.

case "$1" in
   sleep 10
   sleep 20
   echo "Usage: tomcat {start|stop|restart}" >&2
   exit 3

Step 2: Make the script executable

sudo chmod a+x tomcat

Step 3: Test the above script by executing the commands below

sudo ./tomcat start
sudo ./tomcat stop

Step 4: Registering the above script as an init script. The following will make sure to execute “start” or “stop” at the system run levels. Generally default start happens on 2 3 4 5 run levels. Default stop happens on 0 1 6 run levels.

sudo update-rc.d tomcat defaults

Step 5: Now reboot the machine/instance to see everything is fine

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)