Created
September 21, 2017 03:58
-
-
Save diggzhang/f483d53a3d9cea099078e0a42bc16d0c to your computer and use it in GitHub Desktop.
jar package forever load script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jar processing manager @diggzhang20170921 | |
# */5 * * * * cd /home/master/event/ && /usr/bin/sh /home/master/event/jar_pm.sh | |
#!/usr/bin/env bash | |
# ################################################## | |
# Java Processing Manager | |
# | |
version="0.0.1" | |
author="diggzhang@gmail.com" | |
# | |
# HISTORY: | |
# | |
# * 20170921 - v0.0.1 - First Creation | |
# | |
# ################################################## | |
scriptBasename="jar_pm.sh" | |
scriptPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
logFile="/tmp/${scriptBasename}.`date "+%Y%m%d"`.log" | |
procName="eventreceiver-0.0.1-SNAPSHOT-allinone.jar" | |
procPath="/home/master/event/repox-assembly-0.1-SNAPSHOT.jar" | |
echolog() | |
( | |
echo "$1" | |
echo "$1" >> "$logFile" | |
) | |
echolog $scriptPath | |
echolog $logFile | |
proc_num() | |
{ | |
num=`ps -ef | grep $procName | grep -v grep | wc -l` | |
return $num | |
} | |
proc_id() | |
{ | |
pid=`ps -ef | grep $procName | grep -v grep | awk '{print $2}'` | |
} | |
proc_num | |
number=$? | |
echo $number | |
if [ $number -eq 0 ] | |
then | |
nohup java -jar $procPath >> /tmp/$procName_`date "+%Y%m%d"`.log 2>&1 & | |
proc_id | |
echolog ${pid} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment