Script get in process multiple times












0














So i hava a script that Starts|Kill|Restart several java programs.
But wen i execute it get running multiple times in the background.



This is my script



#!/bin/bash

export jvmArgs="-jar -Xms1024m -Xmx2048m -Djava.security.egd=file:/dev/../dev/urandom"

function killer () {
app=$1
kill -9 $(ps -ef | grep ${app} | grep -v grep | awk '{print $2}');

}


function start_acolds ()
{
basePath=/path/to/apps/
cd ${basePath}
cd ${basePath}app0 && nohup java ${jvmArgs} app0.jar >/dev/null 2>&1&
cd ${basePath}app1 && nohup java ${jvmArgs} app1.jar >/dev/null 2>&1&
cd ${basePath}app2 && nohup java ${jvmArgs} app2.jar >/dev/null 2>&1&
cd ${basePath}app3 && nohup java ${jvmArgs} app3.jar >/dev/null 2>&1&
cd ${basePath}app4 && nohup java ${jvmArgs} app4.jar >/dev/null 2>&1&
cd ${basePath}app5 && nohup java ${jvmArgs} app5.jar >/dev/null 2>&1&
cd ${basePath}app6 && nohup java ${jvmArgs} app6.jar >/dev/null 2>&1&
cd ${basePath}app7 && nohup java ${jvmArgs} app7.jar >/dev/null 2>&1&
cd ${basePath}app8 && nohup java ${jvmArgs} app8.jar >/dev/null 2>&1&

}
function kill_acolds(){
killer app0.jar
killer app1.jar
killer app2.jar
killer app3.jar
killer app4.jar
killer app5.jar
killer app6.jar
killer app7.jar
killer app8.jar
}
case "$1" in
start)
echo "Iniciando servicios... "
start_acolds
;;
stop)
echo "Deteniendo servicios..."
kill_acolds
;;
restart)
kill_acolds
start_acolds
;;
*)
echo "Modo de empleo: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0


So wen i execute it, it does hes job, and startkill all programs.
But in the sistem process i see this:



user1@UbuntuMachine:/$ ps -ef|grep -v grep|grep acoldp.sh.dc
user1 12241 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12242 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12243 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12244 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12245 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12246 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12247 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12248 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12249 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12252 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12253 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12254 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12257 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
user1 12258 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart


So, why this get stuck like that, i mean it does it's job buts it bugsme having all that in the backgorund.










share|improve this question







New contributor




Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0














    So i hava a script that Starts|Kill|Restart several java programs.
    But wen i execute it get running multiple times in the background.



    This is my script



    #!/bin/bash

    export jvmArgs="-jar -Xms1024m -Xmx2048m -Djava.security.egd=file:/dev/../dev/urandom"

    function killer () {
    app=$1
    kill -9 $(ps -ef | grep ${app} | grep -v grep | awk '{print $2}');

    }


    function start_acolds ()
    {
    basePath=/path/to/apps/
    cd ${basePath}
    cd ${basePath}app0 && nohup java ${jvmArgs} app0.jar >/dev/null 2>&1&
    cd ${basePath}app1 && nohup java ${jvmArgs} app1.jar >/dev/null 2>&1&
    cd ${basePath}app2 && nohup java ${jvmArgs} app2.jar >/dev/null 2>&1&
    cd ${basePath}app3 && nohup java ${jvmArgs} app3.jar >/dev/null 2>&1&
    cd ${basePath}app4 && nohup java ${jvmArgs} app4.jar >/dev/null 2>&1&
    cd ${basePath}app5 && nohup java ${jvmArgs} app5.jar >/dev/null 2>&1&
    cd ${basePath}app6 && nohup java ${jvmArgs} app6.jar >/dev/null 2>&1&
    cd ${basePath}app7 && nohup java ${jvmArgs} app7.jar >/dev/null 2>&1&
    cd ${basePath}app8 && nohup java ${jvmArgs} app8.jar >/dev/null 2>&1&

    }
    function kill_acolds(){
    killer app0.jar
    killer app1.jar
    killer app2.jar
    killer app3.jar
    killer app4.jar
    killer app5.jar
    killer app6.jar
    killer app7.jar
    killer app8.jar
    }
    case "$1" in
    start)
    echo "Iniciando servicios... "
    start_acolds
    ;;
    stop)
    echo "Deteniendo servicios..."
    kill_acolds
    ;;
    restart)
    kill_acolds
    start_acolds
    ;;
    *)
    echo "Modo de empleo: $0 {start|stop|restart}"
    exit 1
    ;;
    esac
    exit 0


    So wen i execute it, it does hes job, and startkill all programs.
    But in the sistem process i see this:



    user1@UbuntuMachine:/$ ps -ef|grep -v grep|grep acoldp.sh.dc
    user1 12241 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12242 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12243 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12244 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12245 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12246 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12247 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12248 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12249 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12252 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12253 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12254 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12257 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
    user1 12258 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart


    So, why this get stuck like that, i mean it does it's job buts it bugsme having all that in the backgorund.










    share|improve this question







    New contributor




    Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0







      So i hava a script that Starts|Kill|Restart several java programs.
      But wen i execute it get running multiple times in the background.



      This is my script



      #!/bin/bash

      export jvmArgs="-jar -Xms1024m -Xmx2048m -Djava.security.egd=file:/dev/../dev/urandom"

      function killer () {
      app=$1
      kill -9 $(ps -ef | grep ${app} | grep -v grep | awk '{print $2}');

      }


      function start_acolds ()
      {
      basePath=/path/to/apps/
      cd ${basePath}
      cd ${basePath}app0 && nohup java ${jvmArgs} app0.jar >/dev/null 2>&1&
      cd ${basePath}app1 && nohup java ${jvmArgs} app1.jar >/dev/null 2>&1&
      cd ${basePath}app2 && nohup java ${jvmArgs} app2.jar >/dev/null 2>&1&
      cd ${basePath}app3 && nohup java ${jvmArgs} app3.jar >/dev/null 2>&1&
      cd ${basePath}app4 && nohup java ${jvmArgs} app4.jar >/dev/null 2>&1&
      cd ${basePath}app5 && nohup java ${jvmArgs} app5.jar >/dev/null 2>&1&
      cd ${basePath}app6 && nohup java ${jvmArgs} app6.jar >/dev/null 2>&1&
      cd ${basePath}app7 && nohup java ${jvmArgs} app7.jar >/dev/null 2>&1&
      cd ${basePath}app8 && nohup java ${jvmArgs} app8.jar >/dev/null 2>&1&

      }
      function kill_acolds(){
      killer app0.jar
      killer app1.jar
      killer app2.jar
      killer app3.jar
      killer app4.jar
      killer app5.jar
      killer app6.jar
      killer app7.jar
      killer app8.jar
      }
      case "$1" in
      start)
      echo "Iniciando servicios... "
      start_acolds
      ;;
      stop)
      echo "Deteniendo servicios..."
      kill_acolds
      ;;
      restart)
      kill_acolds
      start_acolds
      ;;
      *)
      echo "Modo de empleo: $0 {start|stop|restart}"
      exit 1
      ;;
      esac
      exit 0


      So wen i execute it, it does hes job, and startkill all programs.
      But in the sistem process i see this:



      user1@UbuntuMachine:/$ ps -ef|grep -v grep|grep acoldp.sh.dc
      user1 12241 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12242 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12243 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12244 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12245 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12246 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12247 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12248 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12249 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12252 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12253 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12254 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12257 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12258 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart


      So, why this get stuck like that, i mean it does it's job buts it bugsme having all that in the backgorund.










      share|improve this question







      New contributor




      Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      So i hava a script that Starts|Kill|Restart several java programs.
      But wen i execute it get running multiple times in the background.



      This is my script



      #!/bin/bash

      export jvmArgs="-jar -Xms1024m -Xmx2048m -Djava.security.egd=file:/dev/../dev/urandom"

      function killer () {
      app=$1
      kill -9 $(ps -ef | grep ${app} | grep -v grep | awk '{print $2}');

      }


      function start_acolds ()
      {
      basePath=/path/to/apps/
      cd ${basePath}
      cd ${basePath}app0 && nohup java ${jvmArgs} app0.jar >/dev/null 2>&1&
      cd ${basePath}app1 && nohup java ${jvmArgs} app1.jar >/dev/null 2>&1&
      cd ${basePath}app2 && nohup java ${jvmArgs} app2.jar >/dev/null 2>&1&
      cd ${basePath}app3 && nohup java ${jvmArgs} app3.jar >/dev/null 2>&1&
      cd ${basePath}app4 && nohup java ${jvmArgs} app4.jar >/dev/null 2>&1&
      cd ${basePath}app5 && nohup java ${jvmArgs} app5.jar >/dev/null 2>&1&
      cd ${basePath}app6 && nohup java ${jvmArgs} app6.jar >/dev/null 2>&1&
      cd ${basePath}app7 && nohup java ${jvmArgs} app7.jar >/dev/null 2>&1&
      cd ${basePath}app8 && nohup java ${jvmArgs} app8.jar >/dev/null 2>&1&

      }
      function kill_acolds(){
      killer app0.jar
      killer app1.jar
      killer app2.jar
      killer app3.jar
      killer app4.jar
      killer app5.jar
      killer app6.jar
      killer app7.jar
      killer app8.jar
      }
      case "$1" in
      start)
      echo "Iniciando servicios... "
      start_acolds
      ;;
      stop)
      echo "Deteniendo servicios..."
      kill_acolds
      ;;
      restart)
      kill_acolds
      start_acolds
      ;;
      *)
      echo "Modo de empleo: $0 {start|stop|restart}"
      exit 1
      ;;
      esac
      exit 0


      So wen i execute it, it does hes job, and startkill all programs.
      But in the sistem process i see this:



      user1@UbuntuMachine:/$ ps -ef|grep -v grep|grep acoldp.sh.dc
      user1 12241 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12242 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12243 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12244 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12245 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12246 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12247 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12248 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12249 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12252 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12253 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12254 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12257 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart
      user1 12258 1 0 11:24 pts/1 00:00:00 /bin/bash ./acoldp.sh.dc restart


      So, why this get stuck like that, i mean it does it's job buts it bugsme having all that in the backgorund.







      bash shell-script command-line java






      share|improve this question







      New contributor




      Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 21 mins ago









      Danilo CarenaDanilo Carena

      12




      12




      New contributor




      Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Danilo Carena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Danilo Carena is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493029%2fscript-get-in-process-multiple-times%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Danilo Carena is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Danilo Carena is a new contributor. Be nice, and check out our Code of Conduct.













          Danilo Carena is a new contributor. Be nice, and check out our Code of Conduct.












          Danilo Carena is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493029%2fscript-get-in-process-multiple-times%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          濃尾地震

          How to rewrite equation of hyperbola in standard form

          No ethernet ip address in my vocore2