Tomcat init.d file or startup file for CentOS 7
Here is the sample Apache Tomcat startup script. move this script into the /etc/init.d/ folder.
To run the tomcat as a service use the following script and use it as the systemd service in linux server.
Tomcat Startup Script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#!/bin/bash # description: Tomcat Start Stop Restart # processname: tomcat # chkconfig: 234 20 80 JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-28.b13.el6_6.x86_64/jre/ export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH export PATH CATALINA_HOME=/usr/share/apache-tomcat-8.0.24 case $1 in start) sh $CATALINA_HOME/bin/startup.sh ;; stop) sh $CATALINA_HOME/bin/shutdown.sh ;; restart) sh $CATALINA_HOME/bin/shutdown.sh sh $CATALINA_HOME/bin/startup.sh ;; esac exit 0 |
Once you placed the above init.d script into /etc/init.d folder you can control the tomcat server using the following commands.
To Start Tomcat Server:
/etc/init.d/tomcat start
To stop or shutdown Tomcat Server:
/etc/init.d/tomcat stop
To restart Tomcat Server:
/etc/init.d/tomcat restart