一个简简单单的脚本,启动多个jar包

#!/bin/sh
export items=member-04gateway-1.0-SNAPSHOT.jar
export marketing=member-03user-1.0-SNAPSHOT.jar

# 其实以上就是你的jar包名字,注意=两边不能有空格,不然报错

 
case "$1" in
 
start)
        ## echo 就是一个linux的打印输出语句  
        echo "--------box_items_service 开始启动--------------"
		##  然后就是执行的linux命令
		nohup java -jar $items  > logs/gate &
                
        echo "--------box_items_service 启动成功--------------"
        
        ## 启动营销服务
        echo "--------box_marketing_service 开始启动--------------"
		nohup java -jar $marketing  > logs/user &
       
        echo "--------box_marketing_service 启动成功--------------"
        
		
        echo "===startAll success==="
        ;;
 
 
 
restart)
        $0 stop
        sleep 2
        $0 start
        echo "===restart success==="
        ;;   
esac	
exit 0
 
 
 #启动:sh boxService.sh start
 #停止:sh boxService.sh stop
 #重新:sh boxService.sh restart
 

大概就是这样,等后面在补齐吧,哈哈哈

上面是简化过

这是原版

#!/bin/sh
export items=member-04gateway-1.0-SNAPSHOT.jar
export marketing=member-03user-1.0-SNAPSHOT.jar

# 其实以上就是你的jar包名字,注意=两边不能有空格,不然报错

 
case "$1" in
 
start)
        ## echo 就是一个linux的打印输出语句  
        echo "--------box_items_service 开始启动--------------"
		##  然后就是执行的linux命令
		nohup java -jar $items  > logs/gate &
                
        echo "--------box_items_service 启动成功--------------"
        
        ## 启动营销服务
        echo "--------box_marketing_service 开始启动--------------"
		nohup java -jar $marketing  > logs/user &
       
        echo "--------box_marketing_service 启动成功--------------"
        
		
        echo "===startAll success==="
        ;;
 
 stop)
        
        ## 聚合 和 网关 必须先停掉
        
         P_ID=`ps -ef | grep -w $manageGateway | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===box_manage_gateway process not exists or stop success"
        else
            kill -9 $P_ID
            echo "box_manage_gateway killed success"
        fi
        
        P_ID=`ps -ef | grep -w $manage | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===box_manage_gather process not exists or stop success"
        else
            kill -9 $P_ID
            echo "box_manage_gather killed success"
        fi
        
        
        P_ID=`ps -ef | grep -w $items | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===box_items_service process not exists or stop success"
        else
            kill -9 $P_ID
            echo "box_items_service killed success"
        fi
		
		
		P_ID=`ps -ef | grep -w $marketing | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===box_marketing_service process not exists or stop success"
        else
            kill -9 $P_ID
            echo "box_marketing_service killed success"
        fi
		
		
		P_ID=`ps -ef | grep -w $member | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===box_member_service process not exists or stop success"
        else
            kill -9 $P_ID
            echo "box_member_service killed success"
        fi
        
        
        P_ID=`ps -ef | grep -w $merchants | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===box_merchants_service process not exists or stop success"
        else
            kill -9 $P_ID
            echo "box_merchants_service killed success"
        fi
        
        P_ID=`ps -ef | grep -w $transaction | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===box_transaction_service process not exists or stop success"
        else
            kill -9 $P_ID
            echo "box_transaction_service killed success"
        fi
 
        echo "===stop success==="
        ;;   
 
restart)
        $0 stop
        sleep 2
        $0 start
        echo "===restart success==="
        ;;   
esac	
exit 0
 
 
 #启动:sh boxService.sh start
 #停止:sh boxService.sh stop
 #重新:sh boxService.sh restart
 

现在只是把启动给验证了,后续在来更新


版权声明:本文为m0_60156487原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。