Operating System - HP-UX
1830165 Members
2545 Online
109999 Solutions
New Discussion

Execute 10 scripts concurrently.

 
Gulam Mohiuddin
Regular Advisor

Execute 10 scripts concurrently.

Hi all,

For load stress testing I need to run about 10 or more SQL script files in batch mode simultaneously and concurrently from Unix Shell on our Oracle database Server.

Psoft1.sql, Psoft2.sql ,….., Psot10.sql

What would be the best way to do this?

Thanks,

Gulam
Everyday Learning.
3 REPLIES 3
Pete Randall
Outstanding Contributor

Re: Execute 10 scripts concurrently.

Use another script to send them all into the background:

Psoft1.sql &
Psoft2.sql &
.
.
.

Psoft10.sql &


Pete

Pete
Stuart Abramson
Trusted Contributor

Re: Execute 10 scripts concurrently.

Launch copy scripts from a single script with function defined in base script:

##
# wcshps06:~/scripts/cpio_copy.ksh SDA 10/29/03
#
# Copy two filesystem at once.
#

function cpio_copy
{
FromDir=$1
ToDir=$2
cd $FromDir
date
find . -xdev -depth | cpio -ocax | \
remsh wcshps08 "cd $ToDir ; cpio -icduxm"
date
}

cpio_copy /u413/from /u413/to &
cpio_copy /u425 /u425 &

Launce copy scripts with nohup. Send output to log file.

nohup /var/admtools/copy_script1.ksh 2>&1 >/tmp/log1 &
nohup /var/admtools/copy_script2.ksh 2>&1 >/tmp/log2 &

Notes on Foreground/Background:

17. FOREGROUND/BACKGROUND

a. When you run interactively and you type:

prog

you are running in the foreground.

b. Background:

prog &

c. nohup

nohup prog &

runs to completion in the background with output going to nohup.out.

nohup prog < input file > output_file 2>error_file &

You must use the fully qualified path name for "prog".

d. wait

If you submit a background job from a shell, and want to
the shell to wait until the background job(s) completes,
you use the command:

wait

where pid is optional..

d. EXAMPLE:

stuart@perdita:/users2/bianca/stuart$ lrom &
[1] 8187
Term recognized as HPterm
[1] + Stopped (tty output) lrom &
stuart@perdita:/users2/bianca/stuart$ psg lrom
stuart 8198 8187 0 11:01:02 pts/0 0:00 /opt/lrom/lbin/lromc800
stuart 8187 8171 0 11:01:01 pts/0 0:00 lrom /opt/lrom/bin/lrom
stuart@perdita:/users2/bianca/stuart$ jobs
[1] + Stopped (tty output) lrom &
stuart@perdita:/users2/bianca/stuart$ kill %1
[1] + Terminated lrom &
stuart@perdita:/users2/bianca/stuart$

e. Job Control:

bg PID move to background
fg PID move to foreground
jobs list jobs
kill [signal] PID | %jobno
wait PID

Volker Borowski
Honored Contributor

Re: Execute 10 scripts concurrently.

Like this:

for sqlscript in /path2scripts/*.sql
do
sqlplus /nolog @$sqlscript &
done


Ensure a proper "connect" at the beginning and a proper "exit" ath the end of each script.

Happy stressing
Volker