Linux boot jar

Source: Internet
Author: User

#添加开机启动命令:

# #chmod +x start-all-jar.sh

# #chkconfig--add start-all-jar.sh

# #chkconfig start-all-jar.sh on



============start-all-jar.sh Execute File ==============

#! /bin/sh

# chkconfig:2345 11 80

# Description:start and stop all jar

#export docker_ip=192.168.1.128

#DOCKER_IP =${docker_ip:-0.0.0.0}

# Source function library.

. /etc/init.d/functions


Retval=0

path_version= "0.0.1-snapshot"

Nowtime= ' Date +%y-%m%d-%m%s '

today= ' Date +%y-%m%d '

###### Jar Service Name ######

cd/data/es/openec/

Ls-l *.jar|awk ' {print $NF} ' >/etc/init.d/jarname.txt


#启动服务

function Start_core () {

if [!-D "/data/es/openec/logs"]; Then

mkdir-p/data/es/openec/logs

Fi


echo "#########################################################" >>/data/es/openec/logs/start-${today}_ Out.log

echo "############${nowtime} start service ###############" >>/data/es/openec/logs/start-${today}_out.log


For i in ' cat/etc/init.d/jarname.txt '

Do

_service_name=/data/es/openec/${i}

# _name_suffixx= "\>"

_proc_id= ' ps-ef|grep-i ${_service_name}|grep-v "grep" |awk ' {print $} '


if [! $_proc_id = "]; Then

echo "${i} has been started"

echo "################" >>/data/es/openec/logs/start-${today}_out.lo

echo "${i} has been started"/data/es/openec/logs/start-${today}_out.lo

Echo

Exit

Fi

EXEC java-djava.security.egd=file:/dev/./urandom-jar/data/es/openec/${i} >>/data/es/openec/logs/${i}_${ Nowtime}_out.log &

echo "Java-djava.security.egd=file:/dev/./urandom-jar/data/es/openec/${i}" >>/data/es/openec/logs/start-${ Today}_out.log

echo "Start service ${nowtime}: ${_service_name}"

Echo

Sleep 1

Done

}


#关闭服务

function Stop_core () {

For jarname in ' Cat/etc/init.d/jarname.txt '

Do

Servicename=/data/es/openec/${jarname}

_proc_id= ' ps-ef|grep-i ${servicename}|grep-v "grep" |awk ' {print $} '

if [! $_proc_id = "]; Then

Kill-9 $_proc_id

echo "#########################################################" >>/data/es/openec/logs/stop-${today}_ Out.log

echo "############${nowtime} start service ###############" >>/data/es/openec/logs/stop-${today}_out.log

echo "Close service ${servicename}" >>/data/es/openec/logs/stop-${today}_out.log

echo "Close Service ${servicename}"

Sleep 1

Fi

Done

}


function Corestatus () {

For j in ' Cat/etc/init.d/jarname.txt '

Do

_SERVICENAME=/DATA/ES/OPENEC/${J}

_proc_id= ' Ps-ef|grep "${servicename}" |grep-v "grep" |awk ' {print $} '

if [! $_proc_id = "]; Then

echo "Service ${_servicename} is running"

Echo

Else

echo "Service ${_servicename} has been closed"

Echo

Fi

Done

}


#重启服务

function Restart_core () {

Stop_core

Start_core

}


function Start () {#启动服务的入口函数

Start_core

}

function Stop () {#关闭服务的入口函数

Stop_core

}

#使用case选择

Case $ in

Start

Start_core

;;

Stop

Stop_core

;;

Status

Corestatus

;;

*)

echo "Error choice! Please input start or stop ";;

Esac

Exit $RETVA


Linux boot jar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.