I have a .sh file that looks like the following:
ruby one.rb
ruby two.rb
ruby three.rb
ruby four.rb
ruby five.rb
ruby six.rb
ruby seven.rb
ruby eight.rb
What this does is run the ruby files one by one. How would I go about launching the first four in conjunction and as soon as the first four are done grab the next set. Not sure how to approach this, any advice is appreciated. I want to avoid using rake for now and continue using shell.
Have you tried using &
and wait
?
ruby one.rb &
ruby two.rb &
ruby three.rb &
ruby four.rb &
wait
ruby five.rb &
ruby six.rb &
ruby seven.rb &
ruby eight.rb &
http://tldp.org/LDP/abs/html/subshells.html
Create a text file which looks like:
one.rb
two.rb
three.rb
...and so on. Call it "jobs" or whatever you want. Then, assuming you are running Ubuntu or a similar system:
sudo apt-get install parallel
parallel ruby < jobs
Information on the parallel
command is available here: http://www.gnu.org/software/parallel/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With