ESOURCE_NAME=sch-coupons-1.0-SNAPSHOT.jar tpid=`ps -ef | grep java | grep $ESOURCE_NAME |awk '{print $2}'` if [ ${tpid} ]; then echo '正在停止。。。' kill -15 $tpid fi sleep 5 tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo '进程停止成功!' kill -9 $tpid else echo '停止成功!' echo '正在移动。。。' jar_time=`date +%F-%H-%M-%S` bak_path="/home/project_bak/${jar_time}" echo '移动路径:'${bak_path} mkdir -p ${bak_path} mv ${ESOURCE_NAME} ${bak_path} echo "${ESOURCE_NAME} 移动成功!" fi