bash: start multiple chained commands in background

前端 未结 15 918
生来不讨喜
生来不讨喜 2020-12-07 22:47

I\'m trying to run some commands in paralel, in background, using bash. Here\'s what I\'m trying to do:

forloop {
  //this part is actually written in perl
          


        
15条回答
  •  独厮守ぢ
    2020-12-07 23:27

    Thanks Hugh, that did it:

    adrianp@frost:~$ (echo "started"; sleep 15; echo "stopped")
    started
    stopped
    adrianp@frost:~$ (echo "started"; sleep 15; echo "stopped") &
    started
    [1] 7101
    adrianp@frost:~$ stopped
    
    [1]+  Done                    ( echo "started"; sleep 15; echo "stopped" )
    adrianp@frost:~$ 
    

    The other ideas don't work because they start each command in the background, and not the command sequence (which is important in my case!).

    Thank you again!

提交回复
热议问题