How do you run multiple ruby โ€‹โ€‹files with a shell script?

I have a .sh file that looks like this:

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 does this mean, run ruby โ€‹โ€‹files one at a time. How would I start running the first four together, and once the first four are done, grab the next set. Not sure how to do this, any advice is welcome. I want to avoid using rake and continue using the shell.

+4
source share
3 answers

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

+13
source

Create a text file that looks like this:

  one.rb two.rb three.rb 

... and so on. Call it "jobs" or whatever you want. Then, if you are using 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/

+2
source

Do not avoid rake. Explore it now and benefit.

 require 'rake' run = -> sym { system "ruby #{sym}.rb" } u, v = [:one, :two, :three, :four ], [:five, :six, :seven, :eight] u.each { |sym| task sym do run.( sym ) end } multitask midpoint: u v.each { |sym| task sym => :midpoint do run.( sym ) end } multitask( all: v ).invoke 
0
source

Source: https://habr.com/ru/post/1484728/


All Articles