running two .ksh at exact same time

hi guys

I have

job_RAT.ksh and
job_SWD.ksh

when i run them individually like
./job_RAT.ksh  dev test

./job_SWD.ksh  dev test

they work fine

My requirment is to run the above two .ksh files at exact same time.
I dont have crontab facility enabled at work so crontab scheduling is not an option.

So what i did is create a parent.ksh file and put them like this


#!/bin/ksh
#

./job_RAT.ksh  dev test

./job_SWD.ksh  dev test

exit 0

Open in new window


but it says

./job_RAT.ksh: not found [No such file or directory]
./job_SWD.ksh: not found [No such file or directory]

any idea what is the solution to it ?
and will they run at same time ?

Thanks
royjaydAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
#!/bin/ksh
/path/to/job_RAT.ksh dev test &
/path/to/job_SWD.ksh dev test &

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gheistCommented:
#!/bin/ksh
/path/to/job_RAT.ksh dev test & echo First job runs as $!
/path/to/job_SWD.ksh dev test &
wait

Open in new window

0
Gerwin Jansen, EE MVETopic Advisor Commented:
Hi, both suggestions above work but they start the 2nd process after the first process was started. Question: how exact do you want them started (at the same time)?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Gerwin Jansen, EE MVETopic Advisor Commented:
You could have xargs start the scripts in parallel, like this:

for a in job_RAT.ksh job_SWD.ksh; do echo $a dev test; done | xargs -P 2 -n 3 ksh

Open in new window

The first part (up until | ) will create this list:

job_RAT.ksh dev test
job_SWD.ksh dev test

the second part will start 2 processes in parallel, taking 3 entries each from the first part and use ksh to execute.

If you add an echo in your scripts and start them a few times like this, you'll see that the order in which the 2 scripts are started is not always the same. So the scripts are 'really' started in parallel.
0
TintinCommented:
>Hi, both suggestions above work but they start the 2nd process after the first process was started.

Yes, but with a fraction of a millisecond delay, which is close to being exactly the same time.
0
gheistCommented:
You cannot guarantee that they start at the same time. library linking takes some cpu cycles...
0
Gerwin Jansen, EE MVETopic Advisor Commented:
TinTin, Gheist - agreed, hence my question how exact OP wants the scipts to start. If just running them in parallel is required then & solutions will do fine. But if you try the xargs way you'll see that sometimes the 2nd script gets to output some text first, I've created 2 simple scripts that just echo some text and sleep some time.
0
gheistCommented:
Linux is a timesharing system. Small time slices make illusion that all processes run smoothly all the time.
"Start at the same time" is not very stable. first they load dynamic libraries, then some code starts to run. Given small perturbations in task scheduler one that was started us earlier may print first line ms later.
0
royjaydAuthor Commented:
thanks for all the responses, Since we were already using Autosys, we could schedule it using Autosys tool and run the process at the same time (however there was a millisec difference , which i dont think can be avoided).
0
gheistCommented:
When they run "at the same time" they need couple of disk spins to load executables (if they are loaded the memory space gets shared and no disk access happens). That brings accuracy more into centisecs range. As you see starting same second goes very well with both autosys and cron...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.