需要运行两个ofbiz实例,之前的启动脚本这样获取进程号:
JAVA_ARGS="-jar ofbiz.jar"
/bin/ps h -o pid,args -C java | /bin/grep -e "$JAVA_ARGS" | /bin/egrep -o "^[[:space:]]*[[:digit:]]*"
用来判断ofbiz是否已启动,现在要运行两个ofbiz实例,这样会有两个进程号,所以根据进程的启动路径来判断某个进程号是否属于该ofbiz实例:
procs=$(/bin/ps h -o pid,args -C java | /bin/grep -e "$JAVA_ARGS" | /bin/egrep -o "^[[:space:]]*[[:digit:]]*")
if [ "" == "${procs}" ]; then
OFBIZ_PROCS=""
fi
for pcsid in ${procs}
do
procinfo=$(ls -l /proc/"$pcsid" | grep cwd)
if [ "${procinfo#*->}" == " $OFBIZ_HOME" ]; then
OFBIZ_PROCS=$pcsid
echo "current ofbiz's pid is ${OFBIZ_PROCS}"
break
else
OFBIZ_PROCS=""
fi
done