Running multiple shell instances with different parameters 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












Assume I have a python script that I want to run with different parameter combinations (I have MacBook Pro). If I use a shell script to do so (say run.sh), does it make sense to run run.sh multiple times at the same time, each of which in different parameter combinations? In order word, do different parameter combinations touch each other while both are running in the memory? Is this something like the concept of memory protection?







share|improve this question
























    up vote
    0
    down vote

    favorite












    Assume I have a python script that I want to run with different parameter combinations (I have MacBook Pro). If I use a shell script to do so (say run.sh), does it make sense to run run.sh multiple times at the same time, each of which in different parameter combinations? In order word, do different parameter combinations touch each other while both are running in the memory? Is this something like the concept of memory protection?







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Assume I have a python script that I want to run with different parameter combinations (I have MacBook Pro). If I use a shell script to do so (say run.sh), does it make sense to run run.sh multiple times at the same time, each of which in different parameter combinations? In order word, do different parameter combinations touch each other while both are running in the memory? Is this something like the concept of memory protection?







      share|improve this question












      Assume I have a python script that I want to run with different parameter combinations (I have MacBook Pro). If I use a shell script to do so (say run.sh), does it make sense to run run.sh multiple times at the same time, each of which in different parameter combinations? In order word, do different parameter combinations touch each other while both are running in the memory? Is this something like the concept of memory protection?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 17 at 23:00









      Katherine

      324




      324




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          This depends very much on what the python script and run.sh does.



          So let's take a very simple example:



          #!/bin/bash

          s=$(( RANDOM%5 ))
          echo Sleeping for $s > /tmp/foo
          sleep $s
          echo You entered $1 >> /tmp/foo
          cat /tmp/foo


          Now if I did



          ./run.sh 1 &
          ./run.sh 2 &
          ./run.sh 3 &


          I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo) that can not be accessed multiple times; one script will overwrite the results of another.



          If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:



          #!/bin/bash

          tmpfile=$(mktemp)

          s=$(( RANDOM%5 ))
          echo Sleeping for $s > $tmpfile
          sleep $s
          echo You entered $1 >> $tmpfile
          cat $tmpfile
          rm $tmpfile


          Now you can call this as many times as you like, and it will work properly.



          Well... given memory and CPU limits, of course!






          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%2f424875%2frunning-multiple-shell-instances-with-different-parameters-at-the-same-time%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
            1
            down vote



            accepted










            This depends very much on what the python script and run.sh does.



            So let's take a very simple example:



            #!/bin/bash

            s=$(( RANDOM%5 ))
            echo Sleeping for $s > /tmp/foo
            sleep $s
            echo You entered $1 >> /tmp/foo
            cat /tmp/foo


            Now if I did



            ./run.sh 1 &
            ./run.sh 2 &
            ./run.sh 3 &


            I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo) that can not be accessed multiple times; one script will overwrite the results of another.



            If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:



            #!/bin/bash

            tmpfile=$(mktemp)

            s=$(( RANDOM%5 ))
            echo Sleeping for $s > $tmpfile
            sleep $s
            echo You entered $1 >> $tmpfile
            cat $tmpfile
            rm $tmpfile


            Now you can call this as many times as you like, and it will work properly.



            Well... given memory and CPU limits, of course!






            share|improve this answer
























              up vote
              1
              down vote



              accepted










              This depends very much on what the python script and run.sh does.



              So let's take a very simple example:



              #!/bin/bash

              s=$(( RANDOM%5 ))
              echo Sleeping for $s > /tmp/foo
              sleep $s
              echo You entered $1 >> /tmp/foo
              cat /tmp/foo


              Now if I did



              ./run.sh 1 &
              ./run.sh 2 &
              ./run.sh 3 &


              I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo) that can not be accessed multiple times; one script will overwrite the results of another.



              If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:



              #!/bin/bash

              tmpfile=$(mktemp)

              s=$(( RANDOM%5 ))
              echo Sleeping for $s > $tmpfile
              sleep $s
              echo You entered $1 >> $tmpfile
              cat $tmpfile
              rm $tmpfile


              Now you can call this as many times as you like, and it will work properly.



              Well... given memory and CPU limits, of course!






              share|improve this answer






















                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                This depends very much on what the python script and run.sh does.



                So let's take a very simple example:



                #!/bin/bash

                s=$(( RANDOM%5 ))
                echo Sleeping for $s > /tmp/foo
                sleep $s
                echo You entered $1 >> /tmp/foo
                cat /tmp/foo


                Now if I did



                ./run.sh 1 &
                ./run.sh 2 &
                ./run.sh 3 &


                I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo) that can not be accessed multiple times; one script will overwrite the results of another.



                If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:



                #!/bin/bash

                tmpfile=$(mktemp)

                s=$(( RANDOM%5 ))
                echo Sleeping for $s > $tmpfile
                sleep $s
                echo You entered $1 >> $tmpfile
                cat $tmpfile
                rm $tmpfile


                Now you can call this as many times as you like, and it will work properly.



                Well... given memory and CPU limits, of course!






                share|improve this answer












                This depends very much on what the python script and run.sh does.



                So let's take a very simple example:



                #!/bin/bash

                s=$(( RANDOM%5 ))
                echo Sleeping for $s > /tmp/foo
                sleep $s
                echo You entered $1 >> /tmp/foo
                cat /tmp/foo


                Now if I did



                ./run.sh 1 &
                ./run.sh 2 &
                ./run.sh 3 &


                I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo) that can not be accessed multiple times; one script will overwrite the results of another.



                If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:



                #!/bin/bash

                tmpfile=$(mktemp)

                s=$(( RANDOM%5 ))
                echo Sleeping for $s > $tmpfile
                sleep $s
                echo You entered $1 >> $tmpfile
                cat $tmpfile
                rm $tmpfile


                Now you can call this as many times as you like, and it will work properly.



                Well... given memory and CPU limits, of course!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 18 at 1:30









                Stephen Harris

                21.3k23771




                21.3k23771






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f424875%2frunning-multiple-shell-instances-with-different-parameters-at-the-same-time%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?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay