Reputation: 3667
I want to start a command, wait until it finishes, and then start a series of commands following it, and I would like to chain these together.
I have tried testing with variations of commands using the ; and && operators, but my desired behavior has been expressed.
What I'd like is to run the following:
command1 && command2 && command3; (command4; command5; command6;)
Given the above command, I would want the following to occur:
Run command1
When command1 has successfully completed, start command2
When command2 has successfully completed, start command3
When command3 has succuessfully completed start (command4, command5 and command6) in parallel
Upvotes: 2
Views: 62
Reputation: 2093
This code would achieve what you want:
command1 && command2 && command3; nohup command4 & nohup command5 & nohup command6 &
Note: using nohup
on the terminal (not on a script) can hold the prompt and create a file nohup.out
somewhere if you don't use a redirection such as > /dev/null 2>&1
when invoking it.
Using nohup
would guarantee that the processes invoked with nohup
would continue running even if you close the terminal where you run the command (basically, nohup
runs the given command with hangup signals ignored, so that the command can continue running in the background after you log out).
This simpler code version could also work:
command1 && command2 && command3; command4 & command5 & command6 &
However, if you use the simpler version above and you (for example) close the terminal before (say) command 5
was completed, that command would be interrupted and not finish.
Upvotes: 1