How can one run multiple programs in the background with single command?
From a shell syntax point of view, &
separates commands like ;
/|
/&&
... (though of course with different semantic). So it's just:
cmd1 & cmd2 & cmd3 &
The bash manpage section titled Compound Commands has two options that would work, list and group commands.
A group command is a series of commands enclosed in curly braces {}
. A list is the same, enclosed in parentheses ()
. Both can be used to background multiple commands within, and finally to background the entire collection as a set. The list construct executes commands in a subshell, so variable assignments are not preserved.
To execute a group of commands:
{ command1 & command2 & } &
You can also execute your commands in a list (subshell):
( command1 & command2 ) &
another way:
$(command1 &) && command2 &