startup.sh
#!/bin/bash
#如果沒有tmp_dir目錄則創(chuàng)建
dir="/clh-zq/image"
if [ ! -d "$dir" ];then
mkdir $dir
#項(xiàng)目名
PROJECTNAME=exam_clh_zq
pid=`ps -ef |grep $PROJECTNAME |grep -v "grep" |awk '{print $2}'`
if [ $pid ]; then
?? echo "$PROJECTNAME is running and pid=$pid"
else
? echo "Starting $PROJECTNAME ...."
? nohup java -jar $PROJECTNAME.jar &
fi
stop.sh
#!/bin/bash
PROJECTNAME=exam_clh_zq
pid=`ps -ef |grep $PROJECTNAME |grep -v "grep" |awk '{print $2}' `
if [ $pid ]; then
? ? echo "$PROJECTNAME is? running? and pid=$pid"
? ? kill -9 $pid
? ? if [[ $? -eq 0 ]];then
? ? ? echo "sucess to stop $PROJECTNAME "
? ? else
? ? ? echo "fail to stop $PROJECTNAME "
? ? fi
fi
問題
在從windows中copy到文件后可能出現(xiàn)轉(zhuǎn)義問題等.
方法:
yum -y install dos2unix
dos2unix startup.sh
注意:
stop.sh搜索項(xiàng)目是按文件名搜索
當(dāng)你有A項(xiàng)目叫做project,B項(xiàng)目叫projectB,當(dāng)兩個(gè)項(xiàng)目同時(shí)啟動(dòng)時(shí),你在調(diào)用A的stop.sh時(shí)會(huì)關(guān)閉不掉項(xiàng)目饰序,因?yàn)樗阉鞯降氖且粋€(gè)數(shù)組,假設(shè)你沒有啟動(dòng)項(xiàng)目A,調(diào)用A的stop.sh他會(huì)關(guān)掉B項(xiàng)目