How to run multiple command in one line and some commands in background at the same time?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I know I can use & at the end of a command to make it run in background and && to connect multiple commands at the same line. However, when I use them together it seems not work. Below is an example.



json-server --watch db.json & && python -m http.server 7777


The error message is:



bash: syntax error near unexpected token `&&'


Is it possible to make them work together? Thanks.










share|improve this question

























    up vote
    0
    down vote

    favorite












    I know I can use & at the end of a command to make it run in background and && to connect multiple commands at the same line. However, when I use them together it seems not work. Below is an example.



    json-server --watch db.json & && python -m http.server 7777


    The error message is:



    bash: syntax error near unexpected token `&&'


    Is it possible to make them work together? Thanks.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I know I can use & at the end of a command to make it run in background and && to connect multiple commands at the same line. However, when I use them together it seems not work. Below is an example.



      json-server --watch db.json & && python -m http.server 7777


      The error message is:



      bash: syntax error near unexpected token `&&'


      Is it possible to make them work together? Thanks.










      share|improve this question













      I know I can use & at the end of a command to make it run in background and && to connect multiple commands at the same line. However, when I use them together it seems not work. Below is an example.



      json-server --watch db.json & && python -m http.server 7777


      The error message is:



      bash: syntax error near unexpected token `&&'


      Is it possible to make them work together? Thanks.







      command-line background-process






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 19 at 14:48









      Ogrish Man

      4711414




      4711414




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          It seems you want this



          json-server --watch db.json & python -m http.server 7777


          The && is not to connect multiple commands at the same line, that is ;. The && is a logical AND. You can't use an AND if you don't wait for the command to exit.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f463508%2fhow-to-run-multiple-command-in-one-line-and-some-commands-in-background-at-the-s%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            It seems you want this



            json-server --watch db.json & python -m http.server 7777


            The && is not to connect multiple commands at the same line, that is ;. The && is a logical AND. You can't use an AND if you don't wait for the command to exit.






            share|improve this answer
























              up vote
              5
              down vote



              accepted










              It seems you want this



              json-server --watch db.json & python -m http.server 7777


              The && is not to connect multiple commands at the same line, that is ;. The && is a logical AND. You can't use an AND if you don't wait for the command to exit.






              share|improve this answer






















                up vote
                5
                down vote



                accepted







                up vote
                5
                down vote



                accepted






                It seems you want this



                json-server --watch db.json & python -m http.server 7777


                The && is not to connect multiple commands at the same line, that is ;. The && is a logical AND. You can't use an AND if you don't wait for the command to exit.






                share|improve this answer












                It seems you want this



                json-server --watch db.json & python -m http.server 7777


                The && is not to connect multiple commands at the same line, that is ;. The && is a logical AND. You can't use an AND if you don't wait for the command to exit.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 19 at 14:56









                RalfFriedl

                3,7351623




                3,7351623



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f463508%2fhow-to-run-multiple-command-in-one-line-and-some-commands-in-background-at-the-s%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?