tomcat启动脚本
2015-12-13 23:05
537 查看
#!/bin/bash
#chkconfig: 2345 10 90
source /etc/init.d/functions
if [ -f /etc/system/tomcat ];then
source /etc/system/tomcat
fi
prog=tomcat
tomcat={ /usr/local/tomcat/bin/catalina.sh start &>/dev/null }
pidfile=${pidfile-/var/run/tomcat.pid}
lockfile=${lockfile-/var/lock/subsys/tomcat.lock}
start() {
echo -n "Starting tomcat"
daemon $tomcat $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $pidfile $lockfile
echo
}
stop() {
echo -n "Stoping tomcat"
killproc java
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -rf $pidfile
echo
}
reload() {
echo -n "Reloading tomcat"
killproc java -HUP
echo
}
status() {
netstat -nltp|grep 8080 &>/dev/null && netstat -ntlp | grep 8009 &>/dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ];then
echo "tomcat is running"
else
echo "tomcat is stopped"
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage service tomcat{start|stop|restart|reload}"
esac
note:在脚本编写完成之后,我们会执行下面的操作
chkconfig --add tomcat
chkconfig tomcat on
但是在执行上面命令的过程中,有可能会出现下面的错误
service tomcat does not support chkconfig
解决办法为:在脚本的开头加上
#chkconfig: 2345 10 90
#chkconfig: 2345 10 90
source /etc/init.d/functions
if [ -f /etc/system/tomcat ];then
source /etc/system/tomcat
fi
prog=tomcat
tomcat={ /usr/local/tomcat/bin/catalina.sh start &>/dev/null }
pidfile=${pidfile-/var/run/tomcat.pid}
lockfile=${lockfile-/var/lock/subsys/tomcat.lock}
start() {
echo -n "Starting tomcat"
daemon $tomcat $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $pidfile $lockfile
echo
}
stop() {
echo -n "Stoping tomcat"
killproc java
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -rf $pidfile
echo
}
reload() {
echo -n "Reloading tomcat"
killproc java -HUP
echo
}
status() {
netstat -nltp|grep 8080 &>/dev/null && netstat -ntlp | grep 8009 &>/dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ];then
echo "tomcat is running"
else
echo "tomcat is stopped"
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage service tomcat{start|stop|restart|reload}"
esac
note:在脚本编写完成之后,我们会执行下面的操作
chkconfig --add tomcat
chkconfig tomcat on
但是在执行上面命令的过程中,有可能会出现下面的错误
service tomcat does not support chkconfig
解决办法为:在脚本的开头加上
#chkconfig: 2345 10 90
相关文章推荐
- 【Tomcat】一分钟教你eclipse如何配置tomcat(二)
- 【Tomcat】tomcat简单介绍,安装以及启动(一)
- tomcat+nginx
- windows注册Tomcat服务
- tomcat日志过大优化思路和步骤
- myeclipse中tomcat端口被占用
- linux windows Tomcat内存优化
- Tomcat设置默认启动项目及Java Web工程设置默认启动页面
- Tomcat server.xml配置示例
- Tomcat6 Tomcat7对比测试
- Apache + Tomcat 负载均衡及Session绑定的实现
- tomcat6.exe与tomcat6w.exe的区别
- Web项目无法被tomcat识别导致无法部署的问题
- tomcat server.xml配置文件 解析
- Linux下安装JDK和tomcat
- 关于tomcat连接池爆满导致系统崩溃的问题
- Tomcat源码学习(一)
- Tomcat翻译--JNDI Resources HOW-TO
- Tomcat自动重启脚本
- centos tomcat/resin安装配置 卸载系统自带的java tomcat安装配置 安装JDK resin安装配置 第二十八节课