After building tomcat under Linux, each boot and shutdown goes to Tomcat's Bin directory for execution./startup.sh and./shutdown.sh
This is inconvenient, here's how to start, close, and restart Tomcat like the LS MV CP command
The first step to create a script
Script Creation Path/etc/init.d/tomcat
First execute: Vim/etc/init.d/tomcat the following content according to your own situation (modify/usr/tomcat/apache-tomcat-8.5.23/bin for your Tomcat path) d remove y copy p paste
#!/bin/bash # Description:start or stop the Tomcat # Usage: Tomcat [Start|stop|restart] # Export Path= $PATH: $HOME/bin export bash_env= $HOME/.bashrc export username= "root" Case "$" in start) #startup the Tomcat cd/usr/tomcat/apache-tomcat-8.5.23/bin./startup.sh ;; Stop) # stop Tomcat cd/usr/tomcat/apache-tomcat-8.5.23/bin./shutdown.sh echo "Tomcat stoped" ;; restart) $ stop $ start ; *) echo "Tomcat:usage:tomcat [Start|stop|restart]" exit 1 Esac exit 0
Add Execute Permissions
chmod +x/etc/init.d/tomcat
Create a soft link
Cd/usr/bin
Ln-s/etc/init.d/tomcat
Test
Tomcat start
Tomcat stop
Tomcat restart
Linux Setup Tomcat Quick Start mode