I have a shell script like the following which I want to use to execute a series of commands in a non-blocking way, i.e. as soon as one of the commands in the for loop is execute I want the script continue with the next command.
#!/bin/bash
declare -a parameters=("param1" "param2" "param3")
for parameter in "${parameters[@]}"
do
command="nohup mycommand -p ${parameter} 1> ${parameter}_nohup.out 2>&1 &"
${command}
done
However, for every command the script blocks until it finishes its execution before continuing to the next iteration of the for loop to execute the next command. Moreover, the output of the command is redirected to nohup.out instead of the filename I specify to log the output. Why is the behavior of nohup different inside a shell script?
My distribution is Debian GNU/Linux 8 (jessie)
nohup mycommand -p param1 1> param1_nohup.out 2>&1 &but the output will go to nohoup.out regardless.