【转】Jenkins启动、停止脚本

来源:http://www.cnblogs.com/xiaoxitest/p/6290062.html

1、jenkins下载地址:http://pan.baidu.com/s/1eSHusCi

2、创建shell脚本,如: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
复制代码

3、启动和停止命令

启动命令:./jenkins.sh start

停止命令:./jenkins.sh stop

ps -ef |                              全格式显示当前所有进程
grep cusip_full_is             滤出''cusip_full_is''的进程
grep -v grep                     把''grep''这个进程忽略掉
wc -l                                 看看有多少个进程
awk '{ print $1; }'              输出第一列
原文地址:https://www.cnblogs.com/insist8089/p/7105020.html