Title: RE: schema refreshes (transport tablespace)
An easier solution might be the use of the wait command:
 
rcp srvr1:/u01/f1  srvr2:/u01/f1 &
rcp srvr1:/u01/f2  srvr2:/u01/f2&
wait
rcp srvr1:/u01/f3  srvr2:/u01/f3 &
rcp srvr1:/u01/f4  srvr2:/u01/f4&
wait
etc.etc.
 
Best regards,
Paul Vallee -- [EMAIL PROTECTED] -- 877-PYTHIAN
----- Original Message -----
Sent: Thursday, October 18, 2001 3:45 PM
Subject: RE: schema refreshes (transport tablespace)

This is a script mined from Sun Blueprints (http://www.sun.co.jp/blueprints/0300/oraclescript.pdf).  You feed the script a file name and an optional parallel degree integer.  The input file contains complete commands on each line and your original one with 50 lines is usable as-is.  I attached the script code just in case you have a problem with the PDF file.

Tony Aponte

#! /bin/sh
#
#-------------------------------------------------------------
# message
# Establish a timestamp and echo the message to the screen.
# Tee the output (append) to a unique log file.
#-------------------------------------------------------------
#
message()
{
timestamp=‘date +"%D %T"‘
echo "$timestamp $*" | tee -a $logfile
return
}

#-------------------------------------------------------------
# get_shell
# This function is responsible for establishing the next
# command to be processed. Since multiple processes might
# be requesting a command at the same time, it has a built-#
in locking mechanism.
#-------------------------------------------------------------
#
get_shell()
{
echo "‘date‘ $1 Shell Request $$" >> $lklogfile
# debug locking file
while : # until a command or end
do
next_shell="" # initialize command
if [ ! -s ${workfile} ] # if empty file (end)
then #
break # no more commands
fi #
if [ ! -f $lockfile ] # is there a lock?
then # not yet...
echo $$ > $lockfile # make one
echo "‘date‘ $1 Lock Obtained $$" >> $lklogfile
#debug
if [ "$$" = "‘cat $lockfile‘" ]
# double check that
then # we created it last
next_shell=‘sed -e q $workfile‘
# first line of file
sed -e 1d $workfile > ${workfile}.tmp # Chop 1st line
mv ${workfile}.tmp $workfile
# rename to work file
rm -f $lockfile # turn off lock
echo "‘date‘ $1 Shell Issued " >> $lklogfile #debug
return # done, command in
else # variable "next_shell"
echo "‘date‘ $1 Lock FAULTED $$" >> $lklogfile # debug
fi # double check faulted
# else # locked by other
# echo "‘date‘ $1 Lock Wait $$" >> $lklogfile # debug
fi #
sleep 1 # brief pause
done # try again
return # only if no commands
}

#-------------------------------------------------------------
# paresh_slave
# This code is executed by each of the slaves. It basically
# requests a command, executes it, and returns the status.
#-------------------------------------------------------------
#
paresh_slave()
{
shell_count=0 # Commands done by this slave
get_shell $1 # get next command to execute
while test "$next_shell" != ""
# if no command, all done
do # got a command
shell_count=‘expr $shell_count + 1‘
# increment counter
message "Slave $1: Running Shell $next_shell"
# message
$next_shell # execute command
shell_status=$? # get exit status
if [ "$shell_status" -gt 0 ]
# on error
then # then message
message "Slave $1: ERROR IN Shell $next_shell
status=$shell_status"
echo "Slave $1: ERROR IN Shell $next_shell
status=$shell_status" >> $errfile
fi #
# message "Slave $1: Finished Shell $next_shell"
# message
get_shell $1 # get next command
done # all done
message "Slave $1: Done (Executed $shell_count Shells)"
# message
return # slave complete
}

# paresh_driver
# This code is executed by the top level process only. It
# parses the arguments and spawns the appropriate number
# of slaves. Note that the slaves run this same shell file,
# but the slaves execute different code, based on the
# exported variable PARESH.
#-------------------------------------------------------------
#
paresh_driver()
{
rm -f $lklogfile # start a new log file
if [ "$1" = "" ] # first argument?
then # no?
master_file="master.list" # default value
else # yes?
if [ ! -f "$1" ] # does file exist?
then # no?
echo "$0: Unable to find File $1"
# say so
exit 1 # quit
else # yes?
master_file="$1" # use specified filename
fi
fi
if [ "$2" = "" ] # Second Argument?
then # no?
parallel_count=4# default value
else # Yes?
if [ "$2" -lt 1 ] # Less than 1?
then # Yes?
echo "$0: Parallel Process Count Must be > 0"
# message
exit 1 # quit
else # no?
parallel_count=$2 # Use Specified Count
fi
fi
message "------------------------------" # Startup Banner
message "Master Process ID: $PARESH"
message "Processing File: $master_file"
message "Parallel Count: $parallel_count"
message "Log File: $logfile"
message "------------------------------"
cp $master_file $workfile # make a copy of commands file
while test $parallel_count -gt 0 # Have we started all slaves?
do # Not yet
if [ ! -s $workfile ] # Is there work to do?
then # No?
message "All Work Completed - Stopped Spawning at
$parallel_count"
break # Quit spawning
fi
$0 $parallel_count &# spawn a slave (with slave #)
message "Spawned Slave $parallel_count [pid $!]"
# message
parallel_count=‘expr $parallel_count - 1‘
# decrement counter
done # Next
wait # Wait for all slaves
message "All Done" # message
return # Function Complete
}

#-------------------------------------------------------------
# main
# This is the main section of the program. Because this shell
# file calls itself, it uses a variable to establish whether or
# not it is in Driver Mode or Slave Mode.
#-------------------------------------------------------------
#
if [ "$PARESH" != "" ]# If variable is set
then # then slave mode
workfile=/tmp/paresh.work.$PARESH # Work file with parent pid
lockfile=/tmp/paresh.lock.$PARESH # Lock file with parent pid
lklogfile=/tmp/paresh.lklog.$PARESH
# LockLog file with
# parent pid
logfile=/tmp/paresh.log.$PARESH # Log File with parent pid
errfile=/tmp/paresh.err.$PARESH # Error File with parent pid
paresh_slave $* # Execute Slave Code
else #
PARESH="$$"; export PARESH # Establish Parent pid
workfile=/tmp/paresh.work.$PARESH # Work File with parent pid
lockfile=/tmp/paresh.lock.$PARESH # Lock File with parent pid
lklogfile=/tmp/paresh.lklog.$PARESH
# LockLog File with
# parent pid
logfile=/tmp/paresh.log.$PARESH # Log File with parent pid
errfile=/tmp/paresh.err.$PARESH # Error File with parent pid
rm -f $errfile # remove error file
paresh_driver $* # execute Driver Code
rm -f $workfile # remove work file
rm -f $lklogfile # remove lock log file
if [ -f $errfile ] # Is there was an error
then
message "*************************************************"
message "FINAL ERROR SUMMARY. Errors logged in $errfile"
cat $errfile | tee -a $logfile
message "*************************************************"
exit 1
fi
fi
exit

-----Original Message-----
From: Tatireddy, Shrinivas (MED, Keane)
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 18, 2001 6:20 AM
To: Multiple recipients of list ORACLE-L
Subject: schema refreshes (transport tablespace)


Hi lists,

Can anybody post me the command to run the following:

I need to perform rcp at shell (Solaris) for 50 files. This is part of
schema refreshes/mirrorings using transport tablespace utility.

I am submitting a file that has 50 rcp commands like

rcp srvr1:/u01/f1  srvr2:/u01/f1
rcp srvr1:/u01/f2  srvr2:/u01/f2
rcp srvr1:/u01/f3  srvr2:/u01/f3
rcp srvr1:/u01/f4  srvr2:/u01/f4
.....upto 50 lines.



when I submit this, system is executing only 1 rcp at a time. But I need
to do rcp 2 files at a time. So I chose another alternative.

rcp srvr1:/u01/f1  srvr2:/u01/f1
rcp srvr1:/u01/f2  srvr2:/u01/f2&
rcp srvr1:/u01/f3  srvr2:/u01/f3
rcp srvr1:/u01/f4  srvr2:/u01/f4&
.......upt0 50 lines.

But in this , the system is not doing rcp 2 at a time. It is taking 3 or
4 or 1 at a time.

Is there a way to execute 2 rcp's at any time. using any shell command.

thnx in advance.
srinivas


--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Tatireddy, Shrinivas (MED, Keane)
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to