首页 > 其他 > 详细

ja包启动

时间:2020-04-27 10:31:15      阅读:62      评论:0      收藏:0      [点我收藏+]
#!/bin/bash
tomcat_name=jenkins
tomcat_home=/application/tomcats
SHUTDOWN=$tomcat_home/$tomcat_name/bin/shutdown.sh
STARTTOMCAT=$tomcat_home/$tomcat_name/bin/startup.sh

case $1 in
start)
echo "启动$tomcat_name"
$STARTTOMCAT
;;
stop)
echo "关闭$tomcat_name"
$SHUTDOWN
#pidlist=`ps -ef |grep $tomcat_home/$tomcat_name  |grep -v "grep"|awk ‘{print $2}‘`
#kill -9 $pidlist
;;
restart)
echo "关闭$tomcat_name"
$SHUTDOWN

sleep 3
echo "启动$tomcat_name"
$STARTTOMCAT
;;
*)
echo $"Usage: $0 {start|stop|restart}" 
esac

#!/bin/bash
tomcat_name=jenkins
port=8080
tomcat_home=/application/tomcats
SHUTDOWN=$tomcat_home/$tomcat_name/bin/shutdown.sh
STARTTOMCAT=$tomcat_home/$tomcat_name/bin/startup.sh

start() {
	if      ss -an | grep $port | grep LISTEN >/dev/null 
	then
		echo "$tomcat_name已经启动,请勿重复启动!"
	else
		$STARTTOMCAT
	fi
}

stop() {
        if ss -an | grep $port | grep LISTEN >/dev/null
        then
                $SHUTDOWN
        else
                echo "$tomcat_name 未启动"
        fi
}

case $1 in
start)
echo "启动$tomcat_name"
start
;;
stop)
echo "关闭$tomcat_name"
stop
;;
restart)
echo "关闭$tomcat_name"
stop

sleep 3
echo "启动$tomcat_name"
start
;;
*)
echo $"Usage: $0 {start|stop|restart}" 
esac

查出5个最近修改的文件保留 其他的删除


[root@ceshi jenkins]# ls -lrt |tail -5|awk ‘{print $NF}‘
bin
conf
tomcat.sh
webapps
temp
[root@ceshi jenkins]# ll |grep -v "`ls -lrt |tail -5|awk ‘{print $NF}‘`"

gblgfq08rxvkjppxzz8m9lqqcivmdhzu.yundunwaf4.com

#!/bin/sh
echo "  =====关闭Java应用======"
PROCESS=`ps -ef |grep java |grep -v grep|grep xxx.jar|awk ‘{print $2}‘`
for i in $PROCESS
do
  echo "Kill the $1 process [ $i ]"
  kill -9 $i
done
echo "  =====启动Java应用======"
nohup java -jar xxx.jar  > out.log 2>&1 & 
echo $! > savePid.txt
cat savePid.txt
rm  savePid.txt
#!/bin/sh
export EUREKA=fire-eureka-1.0-ALPHA.jar
export CONFIG=fire-config-1.0-ALPHA.jar
export GATEWAY=fire-gateway-1.0-ALPHA.jar
export AUTH=fire-auth-service-1.0-ALPHA.jar
 
export EUREKA_port=8761
export CONFIG_port=4001
export GATEWAY_port=9999
export AUTH_port=3001
 
case "$1" in
 
start)
        ## 启动eureka
        echo "--------eureka 开始启动--------------"
        nohup java -jar $EUREKA >/dev/null 2>&1 &
        EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk ‘{print $2}‘`
        until [ -n "$EUREKA_pid" ]
            do
              EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk ‘{print $2}‘`  
            done
        echo "EUREKA pid is $EUREKA_pid" 
        echo "--------eureka 启动成功--------------"
 
        ## 启动config
        echo "--------开始启动CONFIG---------------"
        nohup java -jar $CONFIG >/dev/null 2>&1 &
        CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk ‘{print $2}‘` 
        until [ -n "$CONFIG_pid" ]
            do
              CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk ‘{print $2}‘`  
            done
        echo "CONFIG pid is $CONFIG_pid"     
        echo "---------CONFIG 启动成功-----------"
 
        ## 启动gateway
        echo "--------开始启动GATEWAY---------------"
        nohup java -jar $GATEWAY >/dev/null 2>&1 &
        GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk ‘{print $2}‘`
        until [ -n "$GATEWAY_pid" ]
            do
              GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk ‘{print $2}‘`  
            done
        echo "GATEWAY pid is $GATEWAY_pid"    
        echo "---------GATEWAY 启动成功-----------"
 
        ## 启动auth
        echo "--------开始启动AUTH---------------"
        nohup java -jar $AUTH >/dev/null 2>&1 &
        AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk ‘{print $2}‘`
        until [ -n "$AUTH_pid" ]
            do
              AUTH_pid=`lsof -i:$AUTH_port|grep "LISTEN"|awk ‘{print $2}‘`  
            done
        echo "AUTH pid is $AUTH_pid"     
        echo "---------AUTH 启动成功-----------"
        
        echo "===startAll success==="
        ;;
 
 stop)
        P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk ‘{print $2}‘`
        if [ "$P_ID" == "" ]; then
            echo "===EUREKA process not exists or stop success"
        else
            kill -9 $P_ID
            echo "EUREKA killed success"
        fi
		P_ID=`ps -ef | grep -w $CONFIG | grep -v "grep" | awk ‘{print $2}‘`
        if [ "$P_ID" == "" ]; then
            echo "===CONFIG process not exists or stop success"
        else
            kill -9 $P_ID
            echo "CONFIG killed success"
        fi
		 P_ID=`ps -ef | grep -w $GATEWAY | grep -v "grep" | awk ‘{print $2}‘`
        if [ "$P_ID" == "" ]; then
            echo "===GATEWAY process not exists or stop success"
        else
            kill -9 $P_ID
            echo "GATEWAY killed success"
        fi
		 P_ID=`ps -ef | grep -w $AUTH | grep -v "grep" | awk ‘{print $2}‘`
        if [ "$P_ID" == "" ]; then
            echo "===AUTH process not exists or stop success"
        else
            kill -9 $P_ID
            echo "AUTH killed success"
        fi
 
        echo "===stop success==="
        ;;   
 
restart)
        $0 stop
        sleep 2
        $0 start
        echo "===restart success==="
        ;;   
esac	
exit 0
mvn -DskipTests clean package

http://idea.medeming.com/jets/

ja包启动

原文:https://www.cnblogs.com/zdqc/p/12784721.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!