Bash Background – How to Run Multiple Programs in Background with One Command

bashshell-script

How can one run multiple programs in the background with single command?

I have tried the commands below, but they do not work.

nohup ./script1.sh & && nohup ./script2.sh &
-bash: syntax error near unexpected token '&&'

nohup ./script1.sh & ; nohup ./script2.sh &
-bash: syntax error near unexpected token ';'

Best Answer

From a shell syntax point of view, & separates commands like ;/|/&&... (though of course with different semantic). So it's just:

cmd1 & cmd2 & cmd3 &
Related Question