对于linux 不熟的人员,
启动停止服务每次都要输入一长串命令比较复杂,
停止 还需要 找到pid 然后kill
#!/bin/ksh
#START
export JAVA_HOME=/soft/jdk1.8.0_171
export PATH=.:$JAVA_HOME/bin:$PATH
export TOMCAT_HOME=/soft/apache-tomcat-8.5.79/
export TAG="apache-tomcat"
# Variables
export STARTUP_WAIT_INTERVAL=20
export SLEEP_INTERVAL=2
function start_app {
CHECK_COMPONENT=0
CHECK_COMPONENT=$(ps -ef | grep java | grep $TAG | wc -l)
if [ $CHECK_COMPONENT != 0 ]; then
kill_app
fi
nohup $TOMCAT_HOME/bin/startup.sh>$TOMCAT_HOME/logs/start_tomcat.log 2>&1 &
}
#KILL
function kill_app {
KILL_PID=0
KILL_PID=$(ps -ef | grep java | grep $TAG | awk '{print $2}')
if [ $KILL_PID != 0 ]; then
kill -9 $KILL_PID
fi
}
case "$1" in
"start")
start_app
;;
"stop")
kill_app
;;
"restart")
kill_app
start_app
;;
*)
# usage
;;
esac
exit 0
脚本 保存为 run.sh
后续可以使用
run.sh start
run.sh stop
run.sh restart
重启服务
1347

被折叠的 条评论
为什么被折叠?



