真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

shell腳本啟動(dòng)多jar包-創(chuàng)新互聯(lián)

shell腳本啟動(dòng)jar包 一、腳本
  1. 通過(guò) true或false控制是否啟動(dòng)
#!/bin/sh
export common_service_enable=true
export business_service_enable=true
export xiaopandian_web_enable=true
 
export common_service=/mnt/xiaopandian-api/dev-common-service.jar
export business_service=/mnt/xiaopandian-api/dev-business-service.jar
export xiaopandian_web=/mnt/xiaopandian-api/dev-xiaopandian-web.jar

export common_service_port=17001
export business_service_port=17002
export xiaopandian_web_port=17003


 
case "$1" in
 
start)
	if($common_service_enable);then
		## 啟動(dòng)timeservice
		echo "--------common_service 開(kāi)始啟動(dòng)--------------"
		nohup java -jar $common_service >/dev/null 2>&1 &
		common_service_pid=`lsof -i:$common_service_port|grep "LISTEN"|awk '{print $2}'`
		until [ -n "$common_service_pid" ]
		    do
		      common_service_pid=`lsof -i:$common_service_port|grep "LISTEN"|awk '{print $2}'`  
		    done
		echo "common_service pid is $common_service_pid" 
		echo "--------common_service 啟動(dòng)成功--------------"
	fi
 
	if($business_service_enable);then
		## 啟動(dòng)business_service
		echo "--------business_service 開(kāi)始啟動(dòng)--------------"
		nohup java -jar $business_service >/dev/null 2>&1 &
		business_service_pid=`lsof -i:$business_service_port|grep "LISTEN"|awk '{print $2}'`
		until [ -n "$business_service_pid" ]
		    do
		      business_service_pid=`lsof -i:$business_service_port|grep "LISTEN"|awk '{print $2}'`  
		    done
		echo "business_service pid is $business_service_pid" 
		echo "--------business_service 啟動(dòng)成功--------------"
	fi
 
	if($xiaopandian_web_enable);then
		## 啟動(dòng)ftpschedule
		echo "--------xiaopandian_web 開(kāi)始啟動(dòng)--------------"
		nohup java -jar $xiaopandian_web >/dev/null 2>&1 &
		xiaopandian_web_pid=`lsof -i:$xiaopandian_web_port|grep "LISTEN"|awk '{print $2}'`
		until [ -n "$xiaopandian_web_pid" ]
		    do
		      xiaopandian_web_pid=`lsof -i:$xiaopandian_web_port|grep "LISTEN"|awk '{print $2}'`  
		    done
		echo "xiaopandian_web pid is $xiaopandian_web_pid" 
		echo "--------xiaopandian_web 啟動(dòng)成功--------------"
	fi

        echo "===startAll success==="
        ;;
 
 stop)
	## 殺掉common_service
        P_ID=`ps -ef | grep -w ${common_service##*/} | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===common_service process not exists or stop success"
        else
            kill -9 $P_ID
            echo "common_service killed success"
        fi
 
	## 殺掉business_service
	P_ID=`ps -ef | grep -w ${business_service##*/} | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===business_service process not exists or stop success"
        else
            kill -9 $P_ID
            echo "business_service killed success"
        fi
  	## 殺掉xiaopandian_web
	P_ID=`ps -ef | grep -w ${xiaopandian_web##*/} | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===xiaopandian_web process not exists or stop success"
        else
            kill -9 $P_ID
            echo "xiaopandian_web killed success"
        fi
        echo "===stopAll success==="
        ;;   
 
restart)
        $0 stop
        sleep 2
        $0 start
        echo "===restartAll success==="
        ;; 
	
check)
	## 檢查common_service
	P_ID=`ps -ef | grep -w ${common_service##*/} | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===common_service process not alive"
        else
            echo "===common_service process alive"
        fi
 
	## 檢查business_service
	P_ID=`ps -ef | grep -w ${business_service##*/} | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===business_service process not alive"
        else
            echo "===business_service process alive"
        fi
 
	## 檢查xiaopandian_web
	P_ID=`ps -ef | grep -w ${xiaopandian_web##*/} | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "===xiaopandian_web process not alive"
        else
            echo "===xiaopandian_web process alive"
        fi
 
        echo "===check finished==="
        ;;   
esac	
exit 0
二、過(guò)程
  1. 將.sh腳本拖到服務(wù)器

    創(chuàng)新互聯(lián)堅(jiān)持網(wǎng)頁(yè)設(shè)計(jì),我們不會(huì)倒閉、轉(zhuǎn)行,已經(jīng)持續(xù)穩(wěn)定運(yùn)營(yíng)十年。專業(yè)網(wǎng)站制作公司技術(shù),豐富的成功經(jīng)驗(yàn)和創(chuàng)作思維,提供一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶,共同發(fā)展進(jìn)步。我們不僅會(huì)設(shè)計(jì)網(wǎng)站,更會(huì)成都全網(wǎng)營(yíng)銷推廣。幫助中小型企業(yè)在“互聯(lián)網(wǎng)+"的時(shí)代里通過(guò)推廣營(yíng)銷傳播路線轉(zhuǎn)型升級(jí),累計(jì)幫助多家客戶實(shí)現(xiàn)網(wǎng)絡(luò)營(yíng)銷化,與我們一起攜手共創(chuàng)未來(lái)!
  2. 將.sh文件賦予權(quán)限

    chmod 775 XXX.sh
  3. 執(zhí)行

    # 啟動(dòng)
    ./XXX.sh start 
    # 停止
    ./XXX.sh stop
    # 檢查
    ./XXX.sh check
    # 重啟
    ./XXX.sh restart
三、問(wèn)題
  1. Linux執(zhí)行.sh文件,提示No such file or directory的問(wèn)題

    • 原因:在windows中寫(xiě)好shell腳本測(cè)試正常,但是上傳到 Linux 上以腳本方式運(yùn)行命令時(shí)提示No such file or directory錯(cuò)誤,那么一般是文件格式是dos格式的緣故,改成unix 格式即可。一般有如下幾種修改辦法。

    • 解決辦法:

      用vim打開(kāi)該sh文件,輸入:
      :set ff 
      回車,顯示fileformat=dos,重新設(shè)置下文件格式:
      :set ff=unix 
      保存退出: 
      :wq 
      再執(zhí)行,竟然可以了
  2. 解決Ubuntu下編譯.sh文件報(bào)錯(cuò) “[: XXXX: unexpected operator”

    • 原因:因?yàn)閁buntu默認(rèn)的sh是連接到dash的,dash跟bash的不兼容所以出錯(cuò)了。

    • 解決辦法:命令行輸入后,選擇NO

      sudo dpkg-reconfigure dash

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧


文章題目:shell腳本啟動(dòng)多jar包-創(chuàng)新互聯(lián)
分享網(wǎng)址:http://weahome.cn/article/epesd.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部