Shell Script for Websphere MQ Queue Manager start/stop

Hello All,

I am completely new to shell scripting. I had to write a script that starts and stop the queue manager in Websphere MQ. We are on Linux 64-bit patform.
The script should stop the queue manager and all the processes related to websphere MQ. It should be a clean stop. Once the queue manager is stopped, it should start back.

Can some one please help me. Its something urgent !!

Welcome to the forum!

What have you tried so far? Can you post your script that is not working?

Hello Paddy1224,

Welcome to forum, please use code tags for commands/codes/Inputs in your posts as per forum rules. I have made following a sample for MQ (Which I never worked) STOP/START/CHECK script, hope this may help you. You need to take it as a start up and try to change appropriate oath details, with process name etc and let us know then if that helps you.

 PATH=/tmp
STOP_SCRIPT=/tmp/stop_MQ.ksh
START_SCRIPT=/tmp/start_MQ.ksh
 CHECK_SERVICES_STATUS(){
CHECK_STATUS=`ps -ef | grep -v "grep" | grep "MQ_process_name_here_please"`
}
 
STOP_SERVICES() {
CHECK_SERVICES_STATUS
if [[ -n $CHECK_STATUS ]]
then
 $STOP_SCRIPT
 CHECK_SERVICES_STATUS
  if [[ -z $CHECK_STATUS ]]
  then
   echo "All MQ services have been stopped now."
  fi
else
 echo "Seems MQ processes are NOT running."
fi
}
  
 START_SERVICES() {
CHECK_SERVICES_STATUS
if [[ -z $CHECK_STATUS ]]
then
 echo "Seems services are NOT up, starting them now......"
 $START_SCRIPT
 CHECK_SERVICES_STATUS
  if [[ -n $CHECK_STATUS ]]
  then
   echo "All MQ services have been started successfully now."
  else
   echo "Seems services haven't been started please check from your end...."
  fi
else
 echo "Services seems to be already up, please check it...."
fi
}
 
  
 
echo "**************************************************"
echo "Welcome to MENU script for STOPPIN/STARTING MQ processes script:"
echo "Please select appropriate options to use the menu script:
echo "Please enter STOP for stopping services, START for starting services, CHECK for checking status of services, QUIT for quiting the script."
echo ""
echo ""
 echo "1) STOP all MQ processes."     
echo "2) START all MQ processes."
echo "3) CHECK status of all MQ processes."
echo "4) QUIT menu script."
echo "@#"
 read INPUT_FROM_USER
 case ($INPUT_FROM_USER) in 
"STOP") STOP_SERVICES;;
"START") START_SERVICES;;
"CHECK") CHECK_SERVICES_STATUS;;
"*") echo "Please enter STOP or START or CHECK, apart from these 3 no options are allowed."
esac
 

Save above script as eg--> menu.ksh give proper permissions to it with proper details by changing paths etc details for scripts. Hope this helps(enjoy learning).

EDIT: Sorry Aia, I haven't seen your reply before this, but this is not a complete solution it is a start up for user.

NOTE: I haven't tested script it should be taken as a startup and appropriate changes according to user's requirement should be done to it.

Thanks,
R. Singh

1 Like

No worries! You give what you feel you want to give.
However, I think is appropriated to ask what has been the effort done if nothing is shown. That would let you know as well the level of understanding that the person has on the issue and helps you to not assume more than what you have to.