38 lines
1.2 KiB
Bash
38 lines
1.2 KiB
Bash
#!/usr/bin/sh
|
|
OLD_IFS="$IFS"
|
|
IFS=$'\n'
|
|
serverName=$1
|
|
sequence=$2
|
|
httpport=$3
|
|
echo "Check Server Process($serverName,$sequence,$httpport) is running or not."
|
|
for line in `ps -eo pid,args |grep java|tr -s " " `; do
|
|
#echo $line
|
|
IFS=$' '
|
|
line=(`echo $line`);
|
|
processId=${line[0]}
|
|
#echo "ProcessID=$processId"
|
|
# shellcheck disable=SC2068
|
|
for i in ${!line[@]}; do
|
|
tempSplit=(${line[i]})
|
|
array=(${tempSplit//=/ })
|
|
if [[ "$tempSplit" =~ ^-Dsvr.* ]]; then
|
|
tempServerName=${array[1]}
|
|
#echo $tempServerName
|
|
elif [[ "$tempSplit" =~ ^-DSeq.* ]]; then
|
|
tempProcName=${array[1]}
|
|
#echo $tempProcName
|
|
elif [[ "$tempSplit" =~ ^-Dhttp.* ]]; then
|
|
tempHttpPortName=${array[1]}
|
|
#echo $tempHttpPortName
|
|
fi
|
|
done
|
|
if [ "$serverName" = "$tempServerName" -a "$tempProcName" = "$sequence" ] || [ "$tempHttpPortName" = "$httpport" ];
|
|
then
|
|
echo "$processId,serverName($tempServerName, $tempProcName, httpport=$tempHttpPortName) is running ,please check serverName and SequenceNumber or httpport , stopServer or execute this script"
|
|
IFS=$OLD_IFS
|
|
exit 1
|
|
fi
|
|
IFS=$'\n'
|
|
done
|
|
IFS=$OLD_IFS
|