为何linux kill命令同时关了两个tomcat进程

我在linux服务器上通过kill命令,关了一个tomcat,但是把另外一个tomcat也一并关了,这两个tomcat端口号并不一样,请问这是为什么。

2个回答

怎么可能呢?肯定是两个不同的进程。ps -ef | grep tomcat 看一下具体的pid 然后再 kill -9 pid

因为你们没有现在对应 可以使用命令过滤

 # description: Auto-starts tomcat

Dir="/tomcat/"
echo $Dir

RETVAL="0"

# See how we were called.
function start() {
        echo -n "Starting Tomcat: " 
    cd $Dir
        ./bin/startup.sh 
        echo 
}

function stop2() {
        stop
    echo >$Dir/logs/catalina.out
}

function stop() {
    pid=$(ps -ef | grep -v 'grep' | egrep $Dir"bin/bootstrap.jar"| awk '{printf $2 " "}')
    if [ "$pid" != "" ]; then       
                echo -n "tomcat ( pid $pid) is running" 

                echo 

                echo -n $"Shutting down Tomcat: "
        cd $Dir
                ./bin/shutdown.sh

        pid=$(ps -ef | grep -v 'grep' | egrep $Dir"bin/bootstrap.jar"| awk '{printf $2 " "}')
        if [ "$pid" != "" ]; then
            echo "kill tomcat process"
            kill -9 "$pid"
        fi
        else 
                echo "Tomcat is stopped" 
        fi

    status
}

function status()
{
    pid=$(ps -ef | grep -v 'grep' | egrep $Dir"bin/bootstrap.jar"| awk '{printf $2 " "}')
    #echo "$pid"
    if [ "$pid" != "" ]; then
        echo "tomcat is running,pid is $pid"
    else
        echo "tomcat is stopped"
    fi
}



function usage()
{
   echo "Usage: $0 {start|stop|stop2(stop and clear catalina.out)|restart|restart2(clear catalina.out)|reload|status}"
   RETVAL="2"
}

# See how we were called.
RETVAL="0"
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    stop2)
        stop2
        ;;
    restart)
        stop
        start
        ;;
    restart2)
        stop2
        start
        ;;
    reload)
        RETVAL="3"
        ;;

    status)
        status
        ;;
    *)
      usage
      ;;
esac

exit $RETVAL

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐