I am trying to use and bash file .sh
to start other bash files in seperate terminals.
I want them to run one after the other as I use them to copy large numbers of files to the same Hard Drive. However the following Bash starts all at the same time.
#!/bin/bash
gnome-terminal --tab --title="1" -- bash /media/dave/Cloud/Music/2.MakeAlbums/NewMaster1.sh &
wait
gnome-terminal --tab --title="2" -- bash /media/dave/Cloud/Music/2.MakeAlbums/NewMaster2.sh &
wait
echo "Complete"
However my Ubuntu Server (latest release) is not respecting the wait
command.
command &
immediately followed by await
is pointless, it's the same as simplycommand
. Your problem is that thegnome-terminal
command returns immediately, rather than when the command it launches (e.g.NewMaster1.sh
) terminates in its window, but thewait
command can't help you here, it only knows about the direct childgnome-terminal
which returns immediately. Luckilygnome-terminal
has a--wait
option to make it wait for its child, this is what you need.command &
immediately followed by await
is pointless, it's the same as simplycommand
" – Unless there is atrap
. Here there is none, so you're right; but in generalsomething & wait
may make sense.wait
waits for any of them to terminate, it's again obviously different from running them sequentially in the foreground.)