#! /bin/sh# chkconfig:2345 # Description:jenkins .... # This script would be executed *after* all the other init script S. # 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 Here comes the wind. jenkins_root=/home/lanmps/jenkinsjenkinsfilename=jenkins.war# Stop Method stops () { echo "stoping $ Jenkinsfilename "Ps-ef|grep $JENKINSFILENAME |awk ' {print $} ' |while read Piddo kill-9 $pid echo" $pid Kill "Don E}case "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
Save As Jenkins directory under jenkins.sh
Jenkins_root for the Jenkins directory
1.centos
Ln-s/home/lanmps/jenkins/jenkins.sh/etc/init.d/jenkinschkconfig--add jenkinschkconfig--level 345 Jenkins on
Starting mode
/etc/init.d/jenkins start
2.ubuntu
Ln-s/home/lanmps/jenkins/jenkins.sh/etc/init.d/jenkinsupdate-rc.d-f Jenkins Defaults
Starting mode
/etc/init.d/jenkins start
Centos/ubuntu Jenkins.war Self-startup script, Linux startup stop jar package run case