Help in running two processes in parellel

I have a script something like this:

#!/usr/bin/ksh

CLASSPATH=/apps/opt/db2udb/admin/db2bdt/sqllib/java/db2java.zip:/apps/opt/db2udb/admin/db2bdt/sqllib/java/db2jcc.jar:/apps/opt/db2udb/admin/db2bdt/sqllib/function:$CLASSPATH

export CLASSPATH

LD_LIBRARY_PATH=/apps/opt/db2udb/admin/db2bdt/sqllib/lib32:/apps/opt/db2udb/admin/db2bdt/sqllib/lib64:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH

./extractFile.sh

./loadFiles_new.sh

I have another script in "loadFiles_old.sh"

./loadFiles_old.sh

The first script is scheduled in a Cron job to be run every morning at 6 AM. In the script, after the "extractFile.sh" process is completed, along with "loadFiles_new.sh", loadFiles_old.sh should also be run. That means, loadFiles_new.sh and loadFiles_old.sh should be kicked off at the same time. And the should be kicked off, only after the extractFile.sh job is completed. This whole script has to run automatically, without any manual intervention.

In a nutshell, the process is like this.... According to the scheduled time, that is 6 AM in the morning, the script will be run.. once the "extractFile.sh" job is completed, "loadFiles_new.sh" will be run.. At the same time when "loadFiles_new.sh" process has begun, "loadFiles_old.sh" should also be kicked off. Please help me in writing a logic on how to coordiante these two processes to be run in parallel?

Can someone help me out in cracking this...
Help is appreciated. Thanks in advance!!

This coordinates three scripts 1.sh, 2.sh, 3.sh the way you describe

#!/bin/ksh
# mywrapper.shl
/path/to/1.sh
/path/to/2.sh  2>&1 > file2.log &
/path/to/3.sh  2>&1 > file3.log &
wait

This runs 1.sh, then runs 2.sh and 3.sh at the same time and waits until they both finish.

Thanks jim mcnamara for your prompt reply..

Can u please explain it to me how it works and what is # mywrapper.shl ?

Is it because they are being run in the back ground that they run in parellel?

# mywapper.sh1 is a comment.

When the process starts, it executes 1.sh and when that is complete, it spawns a new process for 2.sh (caused by the & at the end of the line), and then immediately spawns 3.sh for the same reason.
The original process then waits for both of the spawned processes to complete.

Heyyy Jim Mcnamara!!!

That worksss!!! I really appreciate it..

U rockkk man!!

Thanks a million!

@ jgt.. I got it.. Thanks a lott!!

I tried running the two processes in parellel, by running them in the background. But, now, the issue is that it is reducing the performance..
If I run them in the foreground, they take only 1 minute to finish. but, if I run them in the bg, they are like taking more than 20 minutes to finish.
Can I improve the performance of the background processes. Is there any way, that I can achieve this.

Any help is highly appreiciated!

use 'nice' to set the priority level.

Heyyy jgt!!

Thanks for ur reply..

nice sets the priorities for the processes. But, I want both the processes to run in parellel.. Is it possible to achieve this with the help of nice...

Please help..