There's a lot of talk online, I just record a
1. Switch to the/etc/init.d/directory
2. sudo vim tomcat
3. Write the following in the open file
#!/bin/SH# Chkconfig:345 About Ten# Description:auto-starts tomcat#/etc/init.d/tomcat# Tomcat Auto-start# Sourcefunctionlibrary.#./etc/init.d/functions# source Networking configuration.#./etc/sysconfig/Networkretval=0Export Jre_home=/usr/share/jdk1.8/Jreexport catalina_home=/opt/source/apache-tomcat-8.0. +Export Catalina_base=/opt/source/apache-tomcat-8.0. +start () {if[-F $CATALINA _home/bin/startup.SH ]; Then Echo$"starting Tomcat"$CATALINA _home/bin/startup.SHRETVAL=$?Echo "OK"return $RETVALfi}stop () {if[-F $CATALINA _home/bin/shutdown.SH ]; Then Echo$"stopping Tomcat"$CATALINA _home/bin/shutdown.SHRETVAL=$?Sleep 1 PS-FWWU Tomcat |grepApache-tomcat|grep-Vgrep|grep-V PID |awk '{print $}'|Xargs Kill-9 Echo "OK"-# [$RETVAL-eq0] &&RM-f/var/lock/.. return $RETVALfi} Case " $" inchstart) Start; stop) stop;; Restart)Echo$"restaring Tomcat" $0StopSleep 1 $0start;;*) Echo$"Usage: $ {Start|stop|restart}"Exit1 ;;EsacExit $RETVAL
4. Sudo sysv-rc-conf open, find the Tomcat column, the place as shown in the fork in the hook, restart the system, and then open the localhost:8080, you can take effect
sudo sysv-rc-conf command attached
Set up tomcat to start automatically with the system under Linux (Ubuntu)