how to time several background processes

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











up vote
3
down vote

favorite
1












I have a script s:



echo a &
echo b &
echo c &


Now I want to know how much time it will take for the script to finish.
I try



time bash s


But it gives me an immediate result which is not the correct one(my script is of course much more complicated than that I've written here and takes a lot of time)
How can I ask time to wait for all the subprocesses to finish.







share|improve this question
























    up vote
    3
    down vote

    favorite
    1












    I have a script s:



    echo a &
    echo b &
    echo c &


    Now I want to know how much time it will take for the script to finish.
    I try



    time bash s


    But it gives me an immediate result which is not the correct one(my script is of course much more complicated than that I've written here and takes a lot of time)
    How can I ask time to wait for all the subprocesses to finish.







    share|improve this question






















      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      I have a script s:



      echo a &
      echo b &
      echo c &


      Now I want to know how much time it will take for the script to finish.
      I try



      time bash s


      But it gives me an immediate result which is not the correct one(my script is of course much more complicated than that I've written here and takes a lot of time)
      How can I ask time to wait for all the subprocesses to finish.







      share|improve this question












      I have a script s:



      echo a &
      echo b &
      echo c &


      Now I want to know how much time it will take for the script to finish.
      I try



      time bash s


      But it gives me an immediate result which is not the correct one(my script is of course much more complicated than that I've written here and takes a lot of time)
      How can I ask time to wait for all the subprocesses to finish.









      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 30 at 11:00









      yukashima huksay

      429217




      429217




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          Add wait to the very end of the script. This will make the script wait for all background processes to exit before continuing.



          The new script:



          echo a &
          echo b &
          echo c &

          wait





          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%2f420636%2fhow-to-time-several-background-processes%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
            4
            down vote



            accepted










            Add wait to the very end of the script. This will make the script wait for all background processes to exit before continuing.



            The new script:



            echo a &
            echo b &
            echo c &

            wait





            share|improve this answer
























              up vote
              4
              down vote



              accepted










              Add wait to the very end of the script. This will make the script wait for all background processes to exit before continuing.



              The new script:



              echo a &
              echo b &
              echo c &

              wait





              share|improve this answer






















                up vote
                4
                down vote



                accepted







                up vote
                4
                down vote



                accepted






                Add wait to the very end of the script. This will make the script wait for all background processes to exit before continuing.



                The new script:



                echo a &
                echo b &
                echo c &

                wait





                share|improve this answer












                Add wait to the very end of the script. This will make the script wait for all background processes to exit before continuing.



                The new script:



                echo a &
                echo b &
                echo c &

                wait






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 30 at 11:02









                Kusalananda

                103k13202318




                103k13202318






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420636%2fhow-to-time-several-background-processes%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?