Harry Boy February 2016

Launch shell script from another script

I have the following shell script

#for i in {0..10}
do
  run my command that takes about 10 seconds with parameter $i
done

How can I get this to run the commands in parallel without using GNU Parallel as I am not able to install it on my linux box.

Is there a way I can create 10 different shell scripts and call them e.g. script_1.sh, script_2.sh, script_3.sh etc and then launch them one by one from this script?

Answers


alpha1554 February 2016

You could use an ampersand (&) and launch script.sh $1 & ten times. This will make the script run in a fork of the main process. It is an easy way to do parallel processing but definitely not very flexible and doesn't have many features. A simple tutorial can be found here.

Post Status

Asked in February 2016
Viewed 3,693 times
Voted 9
Answered 1 times

Search




Leave an answer