Search This Blog

Tuesday, January 20, 2009

Unix/Windows Scripts to Run a Task for "n" number of times

Windows Script
test.bat

FOR /L %%G IN (1,1,20) DO (
echo Ruuning ---> %%G Time
java -jar admin_client.jar deployer:oc4j:opmn://xxx.xx.oracle.com:37005/IAM01 oc4jadmin manager1 -undeploy IAM
java -jar admin_client.jar deployer:oc4j:opmn://xx.xx.oracle.com:37005/IAM01 oc4jadmin manager1 -deploy -file D:\bugs-download\Bug7252754\iam.ear -deploymentName IAM -bindAllWebApps
)

Unix Script



#!/bin/ksh
num=6
while [ $num -lt 20 ]
echo =========== Running for $num on `date` =============
do
opmnctl shutdown
opmnctl startall
opmnctl status
/refresh/jwc1013/product/jwc1013/jdk/bin/java -jar $ORACLE_HOME/j2ee/home/admin_client.jar deployer:oc4j:opmn://xx.xx.oracle.com:35005/IAM oc4jadmin manager1 -undeploy IAM
/refresh/jwc1013/product/jwc1013/jdk/bin/java -jar $ORACLE_HOME/j2ee/home/admin_client.jar deployer:oc4j:opmn://xx.xx.oracle.com:35005/IAM oc4jadmin manager1 -deploy -file $ORACLE_HOME/j2ee/home/iam2.ear -deploymentName IAM -bindAllWebApps
let num+=1
done

Script which runs a task 100 times and after every 5 iterations it will restart the oc4j conatiner.

#!/bin/ksh
num=0
while [ $num -lt 100 ]
do
echo =========== Running for $num on  `date` =============
i1=$(expr $num % 5)
if [ $i1 -lt 1 ] ;
then
echo ======== Starting and Stopping OAS ===========
/home/ias/ias10131/opmn/bin/opmnctl shutdown
/home/ias/ias10131/opmn/bin/opmnctl startall
fi
/home/ias/ias10131/jdk/bin/java -jar $ORACLE_HOME/j2ee/home/admin_client.jar deployer:oc4j:opmn://xx.xx.oracle.com:6005/IAM oc4jadmin welcome1  -undeploy IAM
/home/ias/ias10131/jdk/bin/java -jar $ORACLE_HOME/j2ee/home/admin_client.jar deployer:oc4j:opmn://xx.xx.oracle.com:6005/IAM oc4jadmin welcome1  -deploy -file  /home/ias/ias10131/iam.ear -deploymentName IAM -bindAllWebApps
let num+=1
done

No comments: