how to run multiple shell scripts in parallel

Posted by tom smith on Server Fault See other posts from Server Fault or by tom smith
Published on 2012-03-27T21:08:16Z Indexed on 2012/03/28 5:33 UTC
Read the original article Hit count: 518

Filed under:
|
|

I've got a few test scripts, each of which runs a test php app.

Each script runs forever.

So, cat.sh, dog.sh, and foo.sh, each run a php script, and each shell script runs the php app in a loop, so it runs forever, sleeping after each run.

I'm trying to figure out how to run the scripts in parallel, and at the same time, see the output of the php apps in the stdout/term window.

I thought, simply doing something like

foo.sh > &2
dog.sh > &2
cat.sh > &2

in a shell script would be sufficient, but it's not working.

foo.sh, runs foo.php once, and it runs correctly
dog.sh, runs dog.php in a never ending loop. it runs as expected
cat.sh, runs cat.php in a never ending loop
 *** this never runs!!!

it appears that the shell script never gets to run cat.sh. if i run cat.sh by itself in a separate window/term, it runs as expected...

thoughts/comments

© Server Fault or respective owner

Related posts about bash

Related posts about shell