Linux下Tomcat启动关闭管理脚本

Linux下Tomcat启动关闭管理脚本

先配置好环境变量$TOMCAT_HOME

在/etc/init.d/目录下新建文件tomcat,输入如下内容:
#! /bin/sh
# This shell script enables the automatic use of tomcat
#
# Author:      liuxuanyu<[email protected]>
#

RETVAL=0

start() {
    echo -n "Tomcat Starting..."
 echo
 $TOMCAT_HOME/bin/startup.sh
}

stop() {
    echo -n "Tomcat Stop..."
 echo
 $TOMCAT_HOME/bin/shutdown.sh
}

restart() {
 echo -n "Tomcat restart..."
 echo
 stop
 start
}

case "$1" in
 start)
      start;;
 stop)
   stop;;
 restart)
      restart;;
 *)
    echo $"Usage: $0 {start|stop|restart}"
 exit 1
esac

exit $RETVAL

使用方法:
sudo /etc/init.d/tomcat start
sudo /etc/init.d/tomcat stop
sudo /etc/init.d/tomcat restart

你可能感兴趣的:(Linux下Tomcat启动关闭管理脚本)