Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running command simultaneously, please help 3

Status
Not open for further replies.

h3nd

Programmer
Jul 1, 2006
147
AU
Hi guys,

I really need a favour here.
Currently I have 4 CPUs in my server,

I need to load the 144 data, if I load the data sequencially. It takes about 2.5 hours which is not good.

So I need to load the data 3 data at a time assign to each CPU,

Here's roughly my script atm :
Code:
for file in `ls`
do
    [load command] $file > log$file
done

what I want is roughly like this
Code:
for file in `ls`
do
  [load command] $file > log$file & [load command] $file > log$file & [load command] $file > log$file
done

And I need that 3 loading working independently, so whenever loading finish it doesnt have to wait for other to finish but continue loading the next one.

Can you guys shed some light here ?

Any input will be much appreciated.
 
No, the wait command will simply wait for all background processes running under the current shell to end.

Your code looks okay to me, it must be a problem matching the correct processes in the ps listing? Why not add, for example ps -fu adm | grep "loadcommand" | grep "market" inside the until loop as well so you can see from the output which processes it is matching (or not matching)?

Annihilannic.
 
Thanks Anni,

But dont worry then, I run out the time to test it ..

If I use this script to load it takes 27 mnts.
But if I use wait it loads around 51 mts.

So, there's something wrong with that matching command...

Anyway, could you please help me in my new thread thanks ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top