Reputation: 401
So I'm currently writing a BASH script that scans certain text files. There are thousands of text files so I wrote another script that divides up how many articles there are and distributes the load into other terminals which will then run the scanning script. My problem is that when I run my load distribution script I don't want 10 different terminals popping on my screen. Somehow I have to put these terminals in the background yet still run. I know there is a command &
that supposedly allows you to do this, but the terminals still pop on my screen.
So far I have this command:
for ((i=1; i<=5; i++))
do
gnome-terminal -x ./script $a $b $c $d
done
Five terminals running ./script
pop out on the screen. I want them to just run in the background and so they don't pop on the screen. Simply adding &
to the end of the gnome-terminal
command doesn't work. Any suggestions?
Upvotes: 1
Views: 574
Reputation: 401
Thanks to epx (first person to comment the question) there is actually a very simple way to run 10 different terminals in the background:
screen -d -m ./script
if u run this in a for loop you can create multiple terminals in the background.
Upvotes: 1
Reputation: 5369
You want to use parenthesis to create a subshell:
for ((i=1; i<=5; i++))
do
(./script $a $b $c $d)&
done
Upvotes: 0