How can I run multiple .sh
scripts from one .sh
script and run them all in separate terminals? I already have
/root/A.sh & /root/B.sh & /root/C.sh
The issue is it runs all of these in the same terminal at the same time, and without the &'s
, it runs them when the previous one is finished running, how can I make them all startup at the same time in separate terminals?
Here is one way leveraging gnome terminal tabbing capability :
gnome-terminal \
--tab-with-profile=Default --title=A.sh --command="/root/A.sh" \
--tab-with-profile=Default --title=B.sh --command="/root/B.sh" \
--tab-with-profile=Default --title=C.sh --command="/root/C.sh"&
You can launch your preferred terminal program (i.e. rxvt, xterm, etc) and pass the command to be executed as an option, as in (for instance):
rxvt -display :0 -e "/root/B.sh"&
This assumes you're running on the local console with an X server and window manager.
I'm not at my pc right now, so I can't test this...
Try including the following in your main script to start sh (or whatever shell you prefer) invoking your script as a background task to stop the main script blocking.
sh script1 &
sh script2 &
sh script3 &
Kev
With konsole
, you can have
konsole -e command [args]
e.g.
konsole -e /bin/bash root.sh & ## For konsole, placing it on the background is optional
You can also set the window's title (depends on the version)
konsole -p tabtitle="Window title." -e command [args]
With xterm
:
xterm -e command [args] & ## xterm needs to be placed on background.
Here is a tutorial on how to configure screen for multiple shell sessions and here is another tutorial on using screen
edit
you can check this for using screen and 2 other alternatives for multiprocessing shell