How do I run multiple background commands in bash in a single line?

前端 未结 8 1789
栀梦
栀梦 2020-11-28 19:11

I normally run multiple commands with something like this:

sleep 2 && sleep 3

or

sleep 2 ; sleep 3
<
相关标签:
8条回答
  • 2020-11-28 20:00

    If you want to run multiple commands sequentially, there is a really simple method that works everywhere: Creating a file! The benefit of this method is that it's clean and simple.

    First, create your file with a name, e.g. commands.sh. Then, put your commands there. Here's is a sample:

    commands.sh:

    #!/system/bin/sh
    
    sleep 3;
    sleep 2;
    

    OK, now we're in the last step. To run commands in the background (sequentially), just run:

    $ sh commands.sh &
    
    0 讨论(0)
  • 2020-11-28 20:05

    to run multiple background command you need to add & end of each command. ex: (command1 &) && (command2 &) && (command3 &)

    0 讨论(0)
提交回复
热议问题