background process/command in a script



I have the following MQ Series startup script (below). One of the cmds
in the start section has to start the mq series listener in the
background; otherwise the listener just hangs.

su - ${MQ_USER} -c "runmqlsr -t TCP -p ${MQ_LISTENER_PORT} -m ${mqmgr}
&"



My issue is that I have to put this in as the startup script for a VCS
(veritas cluster) resource group. When I do so, VCS just hangs when I
try to bring the resource on-line.

I suspect it needs a return value that it checks before doing its
validation that the resource started okay.



When I run script directly from the command it works fine, but b/c of
the & the script doesn't complete until you hit enter...then you get
your prompt back.



I looked into job control within shell scripts and I tried a few things
with here documents, but couldn't get it.

Any help or pointers is greatly apprecieated.



root@seieaas45# cat mqseries

#!/bin/sh

set -x



MQ_USER=mqm

MQ_LISTENER_PORT="1414"

MQ_HOME=/opt/mqm

MQ_QMGRS_DIR=/var/mqm/qmgrs



case $1 in

'start')

if [ -x ${MQ_HOME}/bin/strmqm ]; then

for mqmgr in `ls ${MQ_QMGRS_DIR} | grep -vi @system` ; do

echo "Starting MQ Series for ${mqmgr}..."

su - ${MQ_USER} -c "strmqm ${mqmgr}"

sleep 1

ps -ef | grep amqhasmx | grep ${mqmgr} > /dev/null

if [ $? -eq 0 ] ; then

echo "Starting MQ Listener for ${mqmgr} on port
${MQ_LISTENER_PORT}..."

su - ${MQ_USER} -c "runmqlsr -t TCP -p ${MQ_LISTENER_PORT}
-m ${mqmgr} &"

MQ_LISTENER_PORT=`expr ${MQ_LISTENER_PORT} + 1`

fi

done

fi

;;



'stop')

if [ -x ${MQ_HOME}/bin/strmqm ]; then

for mqmgr in `ls ${MQ_QMGRS_DIR} | grep -vi @system` ; do

echo "Stopping MQ Series for ${mqmgr}..."

ps -ef | grep amqhasmx | grep ${mqmgr} > /dev/null

if [ $? -eq 0 ] ; then

su - ${MQ_USER} -c "endmqm -i ${mqmgr}"

sleep 2

echo "Stopping MQ Listener for ${mqmgr}..."

su - ${MQ_USER} -c "endmqlsr -m ${mqmgr}"

fi

done

fi

;;

*)

echo "usage: $0 {start|stop}"

;;

esac



Joe Beck Ciber Inc. - a consultant to SEI One Freedom Valley Drive/ 100
Cider Mill Road| Oaks, PA 19456 | p: 610.676.2258 | jbeck@xxxxxxxx
_______________________________________________
sunmanagers mailing list
sunmanagers@xxxxxxxxxxxxxxx
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



Relevant Pages