Unzip the installed Tomcat, use the Chkconfig command to have Tomcat start randomly, Tomcat into system service

Source: Internet
Author: User

Using the unpacked Tomcat package, the command line input service Tomcat start will report the tomcat:unrecognized service error, meaning that the system did not find the service.

Well, the problem that we are going to solve now is this error hint, let our decompression install version of Tomcat can also support the Yum installation mode of the service Tomcat Start command.

Create a new tomcatd file under the/xxx/tomcat/bin/directory, and edit the following:

#!/bin/Bash # # TOMCATD This shell script takes care of starting and stopping # standalone Tomcat # Chkconfig:345  the Ten# Description:tomcat Service # processname:tomcatd # configfile: # SourcefunctionLibrary:/etc/rc.d/init.d/functions# Source Networking configuration:/etc/sysconfig/network# Check that networking are up.if["${networking}"="No"]; Then    Echo "Network is stoped! Please open the network!"; Exit0fi#执行用户executor=Tomcatprog=Tomcatdexport Java_home=/usr/local/jdk7/Export Catalina_home=/usr/local/tomcat/PATH= $PATH: $JAVA _home/Binstartup="$CATALINA _home/bin/catalina.sh Start"SHUTDOWN="$CATALINA _home/bin/catalina.sh Stop"if[!-F $CATALINA _home/bin/startup.SH]; Then     Echo "Catalina_home for tomcatd not available"Exit0fistart () {# start daemons. Echo-E $"startting Tomcat Service:"     su-$executor-C"$STARTUP"Status RETVAL=$?return $RETVAL}status () {PSAx--width= +|grep "[O]rg.apache.catalina.startup.bootstrap Start"|awk '{printf $ "}'|WC|awk '{print $}'>/tmp/Tomcat_process_count.txt Read line</tmp/Tomcat_process_count.txtif[$line-GT0]; Then        Echo-N"TOMCATD (PID"        PSAx--width= +|grep "[O]rg.apache.catalina.startup.bootstrap Start"|awk '{printf $ "}'        Echo ") is running ..."    Else        Echo "Tomcat is stopped"    fi}stop () {# Stop daemons. Echo-E $"stoping Tomcat Service:"     su-$executor-C"$SHUTDOWN"RETVAL=$?return $RETVAL}# See how we were called.  Case " $" inchstart) Start; stop) stop;; Restart|Reload) StopSleep TenStart RETVAL=$?;; status) Status RETVAL=$?     ;; *)     Echo$"Usage: $ {start|stop|restart|status}"Exit1 EsacExit $RETVAL

chmod a+x/usr/local/tomcat/bin/tomcat  // Configure executable permissions ln -s/usr/local/tomcat/ BIN/TOMCATD/ETC/INIT.D/TOMCATD  // new Soft link 235// set to random start # service TOMCATD status  // view start State

OK, now you can use the lovely service command, The Damned/xxx/tomcat/bin/startup.sh (/xxx/tomcat/bin/catalina.sh start) command to throw aside!

Ps:

http://blog.csdn.net/cnfixit/article/details/7030666

Http://www.jb51.net/article/34332.htm

Http://www.cnblogs.com/panjun-Donet/archive/2010/08/10/1796873.html

Unzip the installed Tomcat, use the Chkconfig command to have Tomcat start randomly, Tomcat into system service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.