centos/ubuntu jenkins.war 自啟動指令碼,Linux啟動停止jar包的運行案例,centosjenkins.war
#! /bin/sh# chkconfig: 2345 10 90 # description: jenkins ....# This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. #prefix=/home/lanmps/jenkins#nohup $prefix/start_jenkins.sh >> $prefix/jenkins.log 2>&1 &#風來了.呆狐狸JENKINS_ROOT=/home/lanmps/jenkinsJENKINSFILENAME=jenkins.war#停止方法stop(){ echo "Stoping $JENKINSFILENAME "ps -ef|grep $JENKINSFILENAME |awk '{print $2}'|while read piddo kill -9 $pid echo " $pid kill"done}case "$1" instart) echo "Starting $JENKINSFILENAME "nohup $JENKINS_ROOT/start_jenkins.sh >> $JENKINS_ROOT/jenkins.log 2>&1 & ;;stop) stop ;;restart) stop start ;;status) ps -ef|grep $JENKINSFILENAME ;;*) printf 'Usage: %s {start|stop|restart|status}\n' "$prog" exit 1 ;;esac
儲存為jenkins目錄下 jenkins.sh
JENKINS_ROOT為 jenkins目錄
1.centos
ln -s /home/lanmps/jenkins/jenkins.sh /etc/init.d/jenkinschkconfig --add jenkinschkconfig --level 345 jenkins on
啟動方式
/etc/init.d/jenkins start
2.ubuntu
ln -s /home/lanmps/jenkins/jenkins.sh /etc/init.d/jenkinsupdate-rc.d -f jenkins defaults
啟動方式
/etc/init.d/jenkins start