Run multiple .sh scripts from one .sh script? Cent

2019-07-24 18:52发布

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?

5条回答
相关推荐>>
2楼-- · 2019-07-24 18:59

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.
查看更多
Summer. ? 凉城
3楼-- · 2019-07-24 19:02

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.

查看更多
聊天终结者
4楼-- · 2019-07-24 19:05

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

查看更多
冷血范
5楼-- · 2019-07-24 19:12

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

查看更多
等我变得足够好
6楼-- · 2019-07-24 19:19

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"&
查看更多
登录 后发表回答