Clear JMS Queue

[wworks@app01 scripts]$ cat clear-jms-queue.sh
#!/bin/bash
#Written 29/10/2010 by Andrew Stringer
#Purpose is to clear the JMS queue files from weblogic app servers.

#Check user is wworks
if [ "$USER" = "wworks" ]; then
   echo "Running as user wworks"
   echo " "
   else
   echo "Sorry, you need to be the wworks user to run this script."
   exit 1
fi
  
echo "Starting clear down of JMS Queue files on RGS Weblogic servers. This will take up to 30 mins to complete"
echo " "
echo "Waiting for 10 seconds before starting. Quit now with Ctrl-C if you do not want to proceed."
sleep 10
echo "OK, proceeding with JMS Queue clearing on app01-04."
  
DELAY=300
  
  
#Local server, rgs-app01
echo "Stopping app01...."
/wworks/rgs/weblogic/prod/bin/weblogic.platform.managed stop
echo "Sleeping for 10 seconds before moving JMS file."
sleep 10
  
mv /wworks/rgs/weblogic/prod/data/jms/FILE-STORE* /var/tmp/
  
echo "Starting app01."
/wworks/rgs/weblogic/prod/bin/weblogic.platform.managed start
sleep 60
  
#Check to see that the new JMS queue has been created.
JMSSIZE=`ls -l /wworks/rgs/weblogic/prod/data/jms/FILE-STORE*`
RESULT=$?
#echo "app01, ${RESULT}"
#echo $JMSSIZE
  
if [ ${RESULT} != 0 ]
   then
   echo "JMS queue has not been created on app01, Quitting!"
   echo "** ATTENTION!!! **"
   exit 1
else
   echo "New JMS Queue has been created on app01, continuing with deleting temporary files."
   rm /var/tmp/FILE-STORE*
fi
   
echo "--------------------------------------------"


 
#Remote servers over ssh
for SERVER in rgs-app02 rgs-app03 rgs-app04
do
  sleep $DELAY
  echo "Stopping ${SERVER}...."
  ssh -q -l wworks ${SERVER} /wworks/rgs/weblogic/prod/bin/weblogic.platform.managed stop
  echo " "
  echo "Sleeping for 10 seconds before moving JMS file."
  sleep 10
  echo " "
  ssh -q -l wworks ${SERVER} "mv /wworks/rgs/weblogic/prod/data/jms/FILE-STORE* /var/tmp/"
  echo "Starting ${SERVER}."
  ssh -q -l wworks ${SERVER} /wworks/rgs/weblogic/prod/bin/weblogic.platform.managed start	
  sleep 60
  JMSSIZE=`ssh -q -l wworks ${SERVER} "ls -l /wworks/rgs/weblogic/prod/data/jms/FILE-STORE*"`
  RESULT=$?
  #echo "Server ${SERVER}, Returncode  ${RESULT} "
  #echo "${JMSSIZE}"
  if [ ${RESULT} != 0 ]
        then
        echo "JMS queue has not been created on ${SERVER}, Quitting!"
	echo "** ATTENTION!!! **"
	exit 1
  else
        echo "New JMS Queue has been created on ${SERVER}, continuing with deleting tempory files."
	ssh -l wworks ${SERVER} rm /var/tmp/FILE-STORE*
  fi
		
  echo "--------------------------------------------"
done
echo "All RGS JMS queues have been cleared."
exit 0

rb/clearjmsqueue.txt · Last modified: 10/10/2013 15:21 (external edit)