linux 执行我自定义的脚本 启动不了tomcat

kidddder
  • 556

我的脚本是:

#! /bin/bash


ACTION=$1
PATH_NAME=$2
PROJECT_NAME=$3
PID=`ps -ef|grep java |grep  /data/tomcat/tomcat-$PATH_NAME/|awk '{print $2}'`
CTIME=`date +"%Y_%m_%d_%H:%M:%S"`


deploy(){
bash /data/tomcat/tomcat-$PATH_NAME/bin/killJvm.sh
bash /data/tomcat/tomcat-$PATH_NAME/bin/killJvm.sh
echo -e "\033[31m 进程已杀死 \033[0m"

echo -e "\033[34m 正在备份tomcat \033[0m"
cp /data/tomcat/tomcat-$PATH_NAME/webapps/$PROJECT_NAME.war /data/backup/$PROJECT_NAME.war
cp /data/tomcat/tomcat-$PATH_NAME/webapps/$PROJECT_NAME.war /data/backup/${PROJECT_NAME}.war_$CTIME


cd /data/tomcat/tomcat-$PATH_NAME/webapps
rm -rf $PROJECT_NAME
cp /data/package/$PROJECT_NAME.war /data/tomcat/tomcat-$PATH_NAME/webapps/
echo -e "测试"
/data/tomcat/tomcat-$PATH_NAME/bin/startup.sh
echo -e "\033[34m tomcat 已经启动了 \033[0m"
}

rollback(){
kill -9 $PID
echo -e "\033[31m 进程已杀死 \033[0m"
echo -e "\033[34m 开始回滚 \033[0m"
cd /data/tomcat/tomcat-$PATH_NAME/webapps/ && rm -rf * && cp /data/backup/$PROJECT_NAME.war ./ 
echo "正在启动tomcat"
rm -rf /data/tomcat/tomcat-$PATH_NAME/work/* /data/tomcat/tomcat-$PATH_NAME/run/*
cd /data/tomcat/tomcat-$PATH_NAME
bash bin/startup.sh
COUNT=0
while [ $COUNT -lt 1 ]; do
    echo -e ".\c"
    sleep 1
    COUNT=`ps -ef|grep java|grep /data/$SERVICE_NAME/|wc -l`
    if [ $COUNT -gt 0 ]; then
        break
    fi
done
echo -e "\033[34m tomcat 已经启动了 \033[0m"
}

restart(){
kill -9 $PID
cd /data/$SERVICE_NAME
rm -rf work/* run/*
su -s /bin/bash tomcat -c /data/$SERVICE_NAME/bin/startup.sh
}

case $ACTION in
  "deploy" )
    deploy
  ;;
  "rollback" )
    rollback
  ;;
  "restart" )
    restart
  ;;
esac

jenkins的命令
image.png
结果
image.png
已经把war包拷贝到webapp下了,可是执行不了
...可我手动的去命令行 启动我的startup.sh是可以的,怎么回事

回复
阅读 885
2 个回答

可以看看tomcat/logs/catalina.log有什么信息没有..
或者直接到ssh上去手动跑这个脚本看看..

jenkins控制台的提示很明显了,按提示去排错,这个与启动脚步没有关系,CP包的时候没有war包

你知道吗?

宣传栏