Monday, November 21, 2011

Stop/Start Specific Concurrent manager script

Hi All


Here the Linux script for stop and start specific concurrent manager (May be scheduled in crontab).


How to use it:
1. Create Linux directory with root user
2. Put the MANAGER_STOP_START.sh and  MANAGER_STOP_START.sql  to created directory
3. chmod +x MANAGER_STOP_START.sh
4. Run the MANAGER_STOP_START.sh with root user using following command:
./MANAGER_STOP_START.sh START/STOP APPS_PWD MANAGER_NAME
where
START- start concurrent manager
STOP - stop concurrent manager
APPS_PWD - Password for APPS schema
MANAGER_NAME - Concurrent manager short name (see the pic below)






Linux Scrip MANAGER_STOP_START.sh:
=========================================

PARAMETER=`echo $1 | tr [a-z] [A-Z]`
APPS_PWD=$2
MANAGER=$3
APPL_USER=<linux appl user >
SCRIPT_PATH=<linux script directory>


if [ "$PARAMETER" = "" ] || [ "$APPS_PWD" = "" ] || [ "$MANAGER" = "" ]
then
echo "Usage: MANAGER_STOP_START.sh START/STOP APPS_PWD MANAGER_NAME"
exit
fi


if [ "$PARAMETER" = "START" ]
then
echo "Starting Manager '" $MANAGER
echo ""
su $APPL_USER -l -c 'sqlplus -s apps/'$APPS_PWD' @'$SCRIPT_PATH'/MANAGER_STOP_START.sql $MANAGER ACTIVATE'
sleep 30
su $APPL_USER -l -c 'sqlplus -s apps/'$APPS_PWD' @'$SCRIPT_PATH'/MANAGER_STOP_START.sql $MANAGER RESUME'
echo ""
echo "***'Manager $MANAGER' STARTED***"
exit
fi


if [ "$PARAMETER" = "STOP" ]
then
echo "Stoping Manager '"$MANAGER
echo ""
su $APPL_USER -l -c 'sqlplus -s apps/'$APPS_PWD' @'$SCRIPT_PATH'/MANAGER_STOP_START.sql $MANAGER DEACTIVATE'
sleep 30
echo ""
echo "***'Manager $MANAGER' STOPED***"
exit
fi


Sql Script MANAGER_STOP_START.sql :
=========================================

REM Start of SCRIPT
REM
SET SERVEROUTPUT ON SIZE 200000
Declare
l_qaid number;
l_queue number;
spid number;
req_data varchar2(10);
errbuf varchar2(300);
Begin
fnd_global.apps_initialize(0,20420,1);
begin
select application_id, CONCURRENT_QUEUE_ID into l_qaid, l_queue
from fnd_concurrent_queues
where CONCURRENT_QUEUE_NAME = '&1';
exception
when others then
l_queue := 0;
end;
if l_queue > 0 then
spid:=fnd_request.submit_svc_ctl_request( command => '&2',
service => '&1',
service_app => 'FND');
end if;
DBMS_OUTPUT.put_line('Appl id: '||l_qaid);
DBMS_OUTPUT.put_line('Queue number: '||l_queue);
DBMS_OUTPUT.put_line('Return Value: '||spid);
if spid = 0 then
errbuf := fnd_message.get;
DBMS_OUTPUT.put_line('--top----');
DBMS_OUTPUT.put_line(errbuf);
DBMS_OUTPUT.put_line('--end----');
end if;
end;
/
commit
/
exit
REM
REM End of Script


Hope it will be useful


Good Luck ...






1 comment: