#简单写了一个tomcat的启动脚本
#!/bin/bash
usage(){echo "Usage: $0 [sart|stop|restart|status]"
}
start(){
/usr/local/tomcat/bin/startup.sh
}
stop(){
TPID=$(ps aux | grep java | grep tomcat | grep -v 'grep' | awk '{print $2}')
kill -9 $TPID
sleep 1;
TSTAT=$(ps aux | grep java | grep tomcat | grep -v 'grep' | awk '{print $2}')
if [-z $TSTAT];then
echo "tomcat stop"
else
kill -9 $TSATA
fi
}
restart(){
/usr/local/tomcat/bin/startup.sh
TPID=$(ps aux | grep java | grep tomcat | grep -v 'grep' | awk '{print $2}')
kill -9 $TPID
sleep 1;
/usr/local/tomcat/bin/startup.sh
}
status(){
ps aux | grep java | grep tomcat | grep -v 'grep'
}
main(){
case $1 in
start)
start_tomcat;;
stop)
stop_tomcat;;
restart)
restart_tomcat;;
status)
status_tomacat;;
*)
usage;;
esac
}
main $1;