TOMCAT LINUX 开机启动
时间:2014-12-25 16:52 来源:linux.it.net.cn 作者:IT
Tomcat 在 Linux 下的自动启动脚本
tomcat shell 代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /bin/sh
# This shell script takes care of starting and stopping
# the glassfish DAS and glassfish instance.
#
# chkconfig: - 64 36
# description: Tomcat auto start
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
#. /etc/init.d/functions
# source networking configuration.
#. /etc/sysconfig/network
RETVAL=0
#export JRE_HOME=/usr/jre1.6.0_22
export CATALINA_HOME=/opt/apache-tomcat-6.0.35
export CATALINA_BASE=/opt/apache-tomcat-6.0.35
start()
{
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
RETVAL=$?
echo " OK"
return $RETVAL
fi
}
stop()
{
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
sleep 1
ps -fwwu yhjhoo | 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
;;
esac
exit $RETVAL
将上面shell 复制到/etc/init.d/tomcat 。
sudo chmod +x /etc/init.d/tomcat
测试/etc/init.d/tomcat start
如果测试成功的话
chkconfig –add tomcat
chkconfig tomcat on
之后进行重启测试
(责任编辑:IT)
Tomcat 在 Linux 下的自动启动脚本tomcat shell 代码
将上面shell 复制到/etc/init.d/tomcat 。 测试/etc/init.d/tomcat start
如果测试成功的话 之后进行重启测试 (责任编辑:IT) |