Linux 多个tomcat,Redis,mysql一键启动脚本

创建 tomcat.sh 文件

获取要启动项目所在位置进行替换即可

#!/bin/bash
ykclient=/data/tomcat/ykclient
ykapp=/data/tomcat/yk-app
ykserver=/data/tomcat/yk-server
ykweb=/data/tomcat/yk-web
bacbi=/data/tomcat/bacbi
 
function tomcatCheck(){
    path=$1
    ps aux|grep $path |grep java|grep -v grep
    if [ $? -ne 0 ];then
        cd $path && ./bin/startup.sh
        echo "$(date +'%Y-%m-%d %H:%M:%S') $path restart" >> $logFile
    fi
}

function controlCheck(){
    cd /data/sskj_install/mybroker/bin
    ./apollo-broker-service start
    cd /data/redis/bin/
    ./redis-server redis.conf 
    service mysqld start
}

function main(){
    tomcatCheck $ykclient
    tomcatCheck $ykapp
    tomcatCheck $ykserver
    tomcatCheck $ykweb
    tomcatCheck $bacbi
    controlCheck
}

main

 拒绝访问时

-bash: ./tomcat.sh: Permission denied
chmod 777 tomcat.sh 开放权限

posted @ 2021-01-15 09:52  海洋svs  阅读(326)  评论(0编辑  收藏  举报