1.创建脚本jenkins.sh

#!/bin/bash
pid=`ps -ef | grep jenkins.war | grep -v 'grep'| awk '{print $2}'| wc -l`
if [ "$1" = "start" ];then
        if [ $pid -gt 0 ];then
    echo 'jenkins is running...'
    else
    java -jar /opt/grow/jenkins.war --httpPort=8060 >/dev/null 2>&1 &
        fi
elif [ "$1" = "stop" ];then
        exec ps -ef | grep jenkins | grep -v grep | awk '{print $2}'| xargs kill -9
    echo 'jenkins is stop..'
else
        echo "Please input like this:"./jenkins.sh start" or "./jenkins stop""
fi

2.启动和停止jenkins
./jenkins.sh start
./jenkins.sh stop

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐