Linux lets Tomcat5 start service scripts automatically

Source: Internet
Author: User

In RH Linux systems, it is not possible to automatically start a $catalina_home/bin/startup.sh if it is simply placed in the/etc/rc.local. There's some work to do here. Assuming that you have installed JSVC (how to install JSVC, check the Tomcat random document), just write the Tomcat startup script as follows:

#!/bin/sh
#
# Startup Script for TOMCAT5
#
# chkconfig:345 88 14
# Description:tomcat Daemon
# PROCESSNAME:JSVC
# Pidfile:/var/run/jsvc.pid
# config:
#
# Source function library.
. /etc/rc.d/init.d/functions
#
# ADAPT The following lines to your configuration
Java_home=/usr/local/jdk
Catalina_home=/usr/local/tomcat
Daemon_home= $CATALINA _home/bin
Tomcat_user=tomcat5
# for multi instances adapt those lines.
Tmp_dir=/usr/local/tomcat/temp
Pid_file=/usr/local/tomcat/logs/jsvc.pid
Catalina_base=/usr/local/tomcat
catalina_opts=
Classpath=
$JAVA _home/lib/tools.jar:
$CATALINA _home/bin/commons-daemon.jar:
$CATALINA _home/bin/bootstrap.jar
Case "$" in
Start
#
# Start Tomcat
#
$DAEMON _home/jsvc
-user $TOMCAT _user
-home $JAVA _home
-dcatalina.home= $CATALINA _home
-dcatalina.base= $CATALINA _base
-djava.io.tmpdir= $TMP _dir
-wait 10
-pidfile $PID _file
-outfile $CATALINA _home/logs/catalina.out
-errfile ' &1 '
$CATALINA _opts
-CP $CLASSPATH
Org.apache.catalina.startup.Bootstrap
#
# to get a verbose JVM
#-verbose
# to get a debug of jsvc.
#-debug
Exit $?
;;
Stop
#
# Stop Tomcat
#
$DAEMON _home/jsvc
-stop
-pidfile $PID _file
Org.apache.catalina.startup.Bootstrap
Exit $?
;;
*)
echo "Usage tomcat.sh start/stop"
Exit 1;;
Esac

Put this script in the/etc/init.d/directory, plus executable permissions, you can use Chkconfig to configure!



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.