linux 启动、关闭、重启tomcat脚本

在开发的时候,有一些服务直接用shutdown.sh 是直接关不掉的,要用 kill -9 xxxx(进程id) 才能关闭,太麻烦了,直接写一个脚本方便一些..
创建一个文件,在里面写如下内容:

!/bin/sh

#

@note tomcat 服务的自启动脚本

@servicename 替换

@path 替换

#

#

#

名字,不影响,可以随便写

servicename=tomcat_7.0.57_news_crawl

tomcat安装的位置

path=/data/tools/tomcat_7.0.57_news_crawl/
cmd=”${path}/bin/startup.sh”

Source tomcat file.

if [ ! -f $cmd ]; then
exit 0
fi

See how we were called.

case “1” in  
  start)  
        # Start daemons.  
        if [ -x
cmd ]; then
$cmd
fi

    echo -n $"[Starting] $path service  "
    echo

    ;;

stop)
# Stop daemons.
pid= (psaux|grep path|grep -v grep|awk ‘{print 2}’)  
        echo -n
"[Stoping] pathservicepid pid ”
echo
[ -n “pid" ] && kill -9pid

    ;;

restart)
0stopsleep1 0 start
;;
*)
echo "Usage: servicename {start|stop|status|restart}”
exit 1
esac

exit 0


上面就是脚本了,可以随便放到一个文件夹里面(我放在了/etc/init.d/,文件名为tomcat_new),直接执行其就可以实现tomcat开启关闭
例如:
开启:/etc/init.d/tomcat_new start
关闭:/etc/init.d/tomcat_new stop
重启:/etc/init.d/tomcat_new restart

猜你喜欢

转载自blog.csdn.net/c910511/article/details/54602481