风.foxwho(神秘狐)

神秘狐,梦想 构架一个世界

centos/ubuntu jenkins.war 自启动脚本,Linux启动停止jar包的运行案例

#! /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/jenkins
JENKINSFILENAME=jenkins.war

#停止方法
stop(){
    echo "Stoping $JENKINSFILENAME "
	ps -ef|grep $JENKINSFILENAME |awk '{print $2}'|while read pid
	do
	   kill -9 $pid
	   echo " $pid kill"
	done
}

case "$1" in
start)
    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目录

#!/bin/bash
JENKINS_ROOT=/home/lanmps/jenkins
export JENKINS_HOME=$JENKINS_ROOT/home
java -jar $JENKINS_ROOT/jenkins.war --httpPort=6700
保存为:start_jenkins.sh

1.centos

ln -s /home/lanmps/jenkins/jenkins.sh /etc/init.d/jenkins
chkconfig --add jenkins
chkconfig --level 345 jenkins on
启动方式
/etc/init.d/jenkins start

2.ubuntu

ln -s /home/lanmps/jenkins/jenkins.sh /etc/init.d/jenkins
update-rc.d -f jenkins defaults
启动方式
/etc/init.d/jenkins start

阅读更多

扫码向博主提问

去开通我的Chat快问

wljk506

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • php
  • java
  • go
  • 架构
  • more
版权声明:原创文章欢迎转载,不过要记得加出处哦 https://blog.csdn.net/wljk506/article/details/42557751
文章标签: ubuntu centos
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭