Linux: Set tomcat to automatically start upon startup

Source: Internet
Author: User

/2/5 Linux: Set tomcat to automatically start a server in the branch after startup. After restart, I always forget to start Tomcat. The developers asked me to set it to automatically start upon startup, however, it took some time to complete the modification. I have referenced several posts on the Internet, but none of them are very suitable. I still need to modify them by myself, probably as follows: [root @ appsit init. d] # pwd
/Etc/init. d
[Root @ appsit init. d] # Cat tomcatd
#! /Bin/sh
# Chkconfig: 345 99 10
# Description: auto-starts Tomcat
#/Etc/init. d/tomcatd
# Tomcat auto-start # source function library.
./Etc/init. d/functions # source networking configuration.
./Etc/sysconfig/networkretval = 0 # catalina_home = "/usr/apps/Apache/tomcat/jakarta-tomcat-4.0.4"
Export java_home =/tomcat/Java/jdk1.5.0 _ 09
Export catalina_home =/tomcat/Apache-Tomcat-5.5.20
Export catalina_base =/tomcat/Apache-Tomcat-5.5.20
Tomcatuser = tomcatstart ()
{
If [-F $ catalina_home/bin/startup. Sh];
Then
Echo $ "Starting Tomcat"
/Bin/su $ tomcatuser-C $ catalina_home/bin/startup. Sh
Retval =$?
Echo "OK"
Return $ retval
Fi
} STOP ()
{
If [-F $ catalina_home/bin/shutdown. Sh];
Then
Echo $ "Stopping Tomcat"
/Bin/su $ tomcatuser-C $ catalina_home/bin/shutdown. Sh
Retval =$?
Sleep 1
PS-fwwu Tomcat | grep APACHE-Tomcat | grep-V grep | grep-v pid | awk '{print $2}' | xargs kill-9
Echo "OK"
# [$ Retval-EQ 0] & Rm-F/var/lock /...
Return $ retval
Fi
} Case "$1" in
Start)
Start
; Stop)
Stop
;;

Restart)
Echo $ "restaring Tomcat"
$0 stop
Sleep 1
$0 start
;;
*)
Echo $ "Usage: $0 {START | stop | restart }"
Exit 1
;;
Esacexit $ retval [root @ appsit init. d] # chmod U + x tomcatd
[Root @ appsit init. d] # chkconfig -- add tomcatd [root @ appsit init. d] # chkconfig -- list tomcatd
Tomcatd 0: off 1: off 2: off 3: On 4: On 5: on 6: off [root @ appsit init. d] # service tomcatd stop Delete: [root @ appsit init. d] # chkconfig -- del tomcatd Not fully written yet. For example, the Tomcat user uses a variable instead of retval =$? To return the exit status of the last command ,... These remain for future improvement You can also refer to this: http://nio.infor96.com/archives/86

Related Article

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.