#添加開機(jī)啟動(dòng)命令:
創(chuàng)新互聯(lián)建站是一家專注于成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)與策劃設(shè)計(jì),永昌網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:永昌等地區(qū)。永昌做網(wǎng)站價(jià)格咨詢:028-86922220
##chmod +x start-all-jar.sh
##chkconfig --add start-all-jar.sh
##chkconfig start-all-jar.sh on
============start-all-jar.sh執(zhí)行文件==============
#! /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 服務(wù)名稱######
cd /data/es/openec/
ls -l *.jar|awk '{print $NF}'> /etc/init.d/jarname.txt
#啟動(dòng)服務(wù)
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} 啟動(dòng)服務(wù)###############" >> /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 $2}'`
if [ ! $_PROC_ID = "" ]; then
echo "${i} 已經(jīng)啟動(dòng)"
echo "################" >> /data/es/openec/logs/start-${today}_out.lo
echo "${i} 已經(jīng)啟動(dòng)" /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 "啟動(dòng)服務(wù)${nowtime} : ${_SERVICE_NAME}"
echo
sleep 1
done
}
#關(guān)閉服務(wù)
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 $2}'`
if [ ! $_PROC_ID = "" ]; then
kill -9 $_PROC_ID
echo "#########################################################" >> /data/es/openec/logs/stop-${today}_out.log
echo "############${nowtime} 啟動(dòng)服務(wù)###############" >> /data/es/openec/logs/stop-${today}_out.log
echo " 關(guān)閉服務(wù)${servicename} " >> /data/es/openec/logs/stop-${today}_out.log
echo " 關(guān)閉服務(wù)${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 $2}'`
if [ ! $_PROC_ID = "" ]; then
echo " 服務(wù)${_servicename} 正在運(yùn)行 "
echo
else
echo " 服務(wù)${_servicename} 已經(jīng)關(guān)閉 "
echo
fi
done
}
#重啟服務(wù)
function restart_core(){
stop_core
start_core
}
function start(){ #啟動(dòng)服務(wù)的入口函數(shù)
start_core
}
function stop(){ #關(guān)閉服務(wù)的入口函數(shù)
stop_core
}
#使用case選擇
case $1 in
start)
start_core
;;
stop)
stop_core
;;
status)
corestatus
;;
*)
echo "error choice ! please input start or stop";;
esac
exit $RETVA
新聞標(biāo)題:linux開機(jī)啟動(dòng)jar
網(wǎng)頁(yè)鏈接:http://jinyejixie.com/article2/pdceoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、網(wǎng)頁(yè)設(shè)計(jì)公司、虛擬主機(jī)、靜態(tài)網(wǎng)站、App設(shè)計(jì)、自適應(yīng)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)