您的位置:首页 > 运维架构 > Shell

shell脚本启动,关闭tomcat

2016-12-01 00:00 337 查看
#/bin/bash
#tomcatname
tomcatname=tomcat6-$1
#tomcat basedir path
tomcatpath=~/$tomcatname
#tomcat catalina.out path
logsout=$tomcatpath/logs/catalina.out
#catalina.out number
outnum=200

#outnum=`echo a = ${$inmun:-300} | awk '{print $3}'`

if [ $# -gt 4 ];then
echo 'Parameters up to four'
elif [ $# -gt 0 ];then
if [ $3 -gt $outnum ];then
outnum=$3
fi
if [ -d $tomcatpath ];then
echo $outnum 'out'
pid=`ps -ef | grep $tomcatname |grep -v grep |awk '{print $2}'`

if [ $2 == 'out' ];then
tail -fn $outnum $logsout
fi

if [ -n $pid ];then
kill -9 $pid
echo 'kill $pid $tomcatname'
sh $tomcatpath/bin/startup.sh

tail -fn $outnum $logsout
fi
else
echo "error ex :sh start.sh user|goods|order|oth [out] [num]"
fi
else
echo "error ex :sh start.sh user|goods|order|oth [out] [num]"
fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell tomcat 脚本