Step One: Create a new file Tomcat under/ETC/INIT.D (requires root operation permission)
Vi/etc/init.d/tomcat
Then click "I" to write down the following code, Tomcat self-startup script
(Note: You need to modify the following 3 sections of the path "Export jre_home=/usr/jdk1.8.0_131", "Export Catalina_home=/usr/tomcat6", "Export catalina_base=/ Usr/tomcat6 ")
:
#!/bin/sh
# chkconfig:345 99 10
# Description:auto-starts Tomcat
#/etc/init.d/tomcat
# Tomcat Auto-start
# Source function library.
#. /etc/init.d/functions
# source Networking configuration.
#. /etc/sysconfig/network
Retval=0
Export jre_home=/usr/jdk1.8.0_131
Export CATALINA_HOME=/USR/TOMCAT6
Export CATALINA_BASE=/USR/TOMCAT6
Start ()
{
If [f $CATALINA _home/bin/startup.sh];
Then
echo $ "Starting Tomcat"
$CATALINA _home/bin/startup.sh
Retval=$?
echo "OK"
Return $RETVAL
Fi
}
Stop ()
{
If [f $CATALINA _home/bin/shutdown.sh];
Then
echo $ "Stopping Tomcat"
$CATALINA _home/bin/shutdown.sh
Retval=$?
Sleep 1
PS-FWWU Tomcat | grep apache-tomcat|grep-v grep | Grep-v PID | awk ' {print $} ' |xargs kill-9
echo "OK"
# [$RETVAL-eq 0] && rm-f/var/lock/...
Return $RETVAL
Fi
}
Case "$" in
Start
Start
;;
Stop
Stop
;;
Restart)
echo $ "restaring Tomcat"
$ stop
Sleep 1
$ start
;;
*)
echo $ "Usage: $ {Start|stop|restart}"
Exit 1
;;
Esac
Exit $RETVAL
Finally click "Esc" and enter ": Wq"
Step two, set permissions
chmod +x/etc/init.d/tomcat
third step, set up boot service
sudo chkconfig tomcat on
Step Fourth, verify
Reboot the server, and then access