[root@Tomcat conf]# cd /opt/
[root@Tomcat opt]# ll
total 16
drwxr-xr-x. 8 500 500 4096 Apr 4 19:52 jdk1.7.0_21
drwxr-xr-x. 2 root root 4096 May 10 2012 rh
drwxr-xr-x. 9 root root 4096 May 31 00:23 TomcatA
drwxr-xr-x. 9 root root 4096 May 31 00:26 TomcatB
[root@Tomcat opt]# ls /etc/init.d/Tomcat*
/etc/init.d/TomcatA /etc/init.d/TomcatB
[root@Tomcat opt]# ls /tmp/
hsperfdata_root tomcatA_process_count.txt tomcatB_process_count.txt yum.log
[root@Tomcat opt]# chkconfig --add TomcatA
[root@Tomcat opt]# chkconfig --add TomcatB
[root@Tomcat opt]# chkconfig --list|grep Tomcat
TomcatA 0:off 1:off 2:on 3:on 4:on 5:on 6:off
TomcatB 0:off 1:off 2:on 3:on 4:on 5:on 6:off
-
[root@Tomcat bin]# more /etc/init.d/TomcatA
-
#!/bin/bash
-
#chkconfig: 2345 10 90
-
#description:TomcatA service
-
JAVA_HOME=/opt/jdk1.7.0_21
-
CATALINA_HOME=/opt/TomcatA
-
TOMCAT_START=$CATALINA_HOME/bin/startup.sh
-
TOMCAT_STOP=$CATALINA_HOME/bin/shutdown.sh
-
-
# source function library.
-
. /etc/rc.d/init.d/functions
-
# check that networking is up.
-
[ "${NETWORKING}" = "no" ] && exit 0
-
# check for tomcat script
-
if [ ! -f $CATALINA_HOME/bin/catalina.sh ]; then
-
echo "TomcatA not valilable..."
-
exit
-
fi
-
start(){
-
echo -n "Starting TomcatA: "
-
daemon $TOMCAT_START
-
echo
-
touch /var/lock/subsys/tomcat
-
}
-
stop(){
-
ps ax --width=1000 | grep "/opt/TomcatA/temp [o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
-
| wc | awk '{print $2}' > /tmp/tomcatA_process_count.txt
-
read line < /tmp/tomcatA_process_count.txt
-
if [ $line -gt 0 ]; then
-
echo -n "TomcatA ( pid "
-
ps ax --width=1000 | grep "/opt/TomcatA/temp org.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
-
echo -n ") is running..."
-
echo
-
-
echo -n $"Shutting down TomcatA: "
-
daemon $TOMCAT_STOP
-
rm -f /var/lock/subsys/tomcat.pid echo
-
else
-
echo "TomcatA is stopped"
-
fi
-
}
-
restart(){
-
stop
-
start
-
}
-
status(){
-
ps ax --width=1000 | grep "/opt/TomcatA/temp [o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
-
| wc | awk '{print $2}' > /tmp/tomcatA_process_count.txt
-
read line < /tmp/tomcatA_process_count.txt
-
if [ $line -gt 0 ]; then
-
echo -n "TomcatA ( pid "
-
ps ax --width=1000 | grep "/opt/TomcatA/temp org.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
-
echo -n ") is running..."
-
echo
-
else
-
echo "TomcatA is stopped"
-
fi
-
}
-
case "$1" in
-
start)
-
start ;;
-
stop)
-
stop ;;
-
restart)
-
stop
-
sleep 3
-
start ;;
-
status)
-
status ;;
-
*)
-
echo "Usage: TomcatA {start|stop|restart|status}"
-
exit 1
-
esac
-
exit 0
-
-
[root@Tomcat bin]#
阅读(11803) | 评论(2) | 转发(1) |