美文网首页
【Shell Script】杀死某个程序并重新启动

【Shell Script】杀死某个程序并重新启动

作者: Lyudmilalala | 来源:发表于2021-04-27 00:23 被阅读0次
    #!/bin/sh
    
    #cur location is /var/lib/jenkins/workspace/{project_name}
    echo "[INFO] environment = $environment, jar_name = $jar_name"
    jar_path="target/"$jar_name
    mvn clean install -Dmaven.test.skip=true -P $environment
    echo "[INFO] Build finished."
    # if jar is currently running, kill the old process
    pid=`ps -ef | grep ${jar_name} | grep -v grep | awk '{print $2}'`
    if [ -n "$pid" ]
    then
    echo "[INOF] Kill old server."
    kill -15 $pid
    fi
    # start the new process
    nohup java -jar $jar_path
    

    相关文章

      网友评论

          本文标题:【Shell Script】杀死某个程序并重新启动

          本文链接:https://www.haomeiwen.com/subject/wynyrltx.html