How to write a startup script












0















I want to write a startup script file, that start my kafka environment.



I tried as following:



#!/bin/bash
/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


The problem is, it starts only the zookeeper but not kafka server.

What am I doing wrong?










share|improve this question



























    0















    I want to write a startup script file, that start my kafka environment.



    I tried as following:



    #!/bin/bash
    /usr/local/zookeeper-3.4.11/bin/zkServer.sh start
    /usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


    The problem is, it starts only the zookeeper but not kafka server.

    What am I doing wrong?










    share|improve this question

























      0












      0








      0








      I want to write a startup script file, that start my kafka environment.



      I tried as following:



      #!/bin/bash
      /usr/local/zookeeper-3.4.11/bin/zkServer.sh start
      /usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


      The problem is, it starts only the zookeeper but not kafka server.

      What am I doing wrong?










      share|improve this question














      I want to write a startup script file, that start my kafka environment.



      I tried as following:



      #!/bin/bash
      /usr/local/zookeeper-3.4.11/bin/zkServer.sh start
      /usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


      The problem is, it starts only the zookeeper but not kafka server.

      What am I doing wrong?







      scripts






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 28 '17 at 10:45









      zero_codingzero_coding

      1781212




      1781212






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Assuming that this script doesn't need sudo privileges.



          One way to autostart a script is use a Desktop Autostarting method.



          In Ubuntu you can do it like this,




          • Create a file in .config/autostart from your home directory with an extension of .desktop


          Say you created zookeeper.desktop then open and include this format.



          For Zookeeper Entry



          [Desktop Entry]

          Type=Application

          Name=Zookeeper

          Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start


          Then create a separate one for:



          For Kafra Entry



          [Desktop Entry]

          Type=Application

          Name=kafra

          Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


          or just the script your made



          For your Script Entry



          [Desktop Entry]

          Type=Application

          Name=/name/of/your/script

          Exec=/path/to/your/script


          Then you can do it like this(sudo)



          add the path of your script to /etc/rc.local(open and edit rc.local)



          /path/to/your/script &



          exit 0



          if it doesn't exist but it your system have /etc/rc.d1 to 6
          just simply add your script inside that folder and will be executed with sudo rights.






          share|improve this answer


























          • I've forgot to mentioned. The script needs sudo privileges.

            – zero_coding
            Nov 29 '17 at 8:28











          • Edited, just now

            – Yien
            Nov 29 '17 at 9:10



















          0














          A variant of the approach described above is to modify the Exec command in the .desktop file as follows:



              Exec=gnome-terminal -- /path/to/your/script.sh start


          This has two advantages




          1. You can store your script anywhere you like without having to modify anything in rc.local or /etc

          2. You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f981047%2fhow-to-write-a-startup-script%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Assuming that this script doesn't need sudo privileges.



            One way to autostart a script is use a Desktop Autostarting method.



            In Ubuntu you can do it like this,




            • Create a file in .config/autostart from your home directory with an extension of .desktop


            Say you created zookeeper.desktop then open and include this format.



            For Zookeeper Entry



            [Desktop Entry]

            Type=Application

            Name=Zookeeper

            Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start


            Then create a separate one for:



            For Kafra Entry



            [Desktop Entry]

            Type=Application

            Name=kafra

            Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


            or just the script your made



            For your Script Entry



            [Desktop Entry]

            Type=Application

            Name=/name/of/your/script

            Exec=/path/to/your/script


            Then you can do it like this(sudo)



            add the path of your script to /etc/rc.local(open and edit rc.local)



            /path/to/your/script &



            exit 0



            if it doesn't exist but it your system have /etc/rc.d1 to 6
            just simply add your script inside that folder and will be executed with sudo rights.






            share|improve this answer


























            • I've forgot to mentioned. The script needs sudo privileges.

              – zero_coding
              Nov 29 '17 at 8:28











            • Edited, just now

              – Yien
              Nov 29 '17 at 9:10
















            1














            Assuming that this script doesn't need sudo privileges.



            One way to autostart a script is use a Desktop Autostarting method.



            In Ubuntu you can do it like this,




            • Create a file in .config/autostart from your home directory with an extension of .desktop


            Say you created zookeeper.desktop then open and include this format.



            For Zookeeper Entry



            [Desktop Entry]

            Type=Application

            Name=Zookeeper

            Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start


            Then create a separate one for:



            For Kafra Entry



            [Desktop Entry]

            Type=Application

            Name=kafra

            Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


            or just the script your made



            For your Script Entry



            [Desktop Entry]

            Type=Application

            Name=/name/of/your/script

            Exec=/path/to/your/script


            Then you can do it like this(sudo)



            add the path of your script to /etc/rc.local(open and edit rc.local)



            /path/to/your/script &



            exit 0



            if it doesn't exist but it your system have /etc/rc.d1 to 6
            just simply add your script inside that folder and will be executed with sudo rights.






            share|improve this answer


























            • I've forgot to mentioned. The script needs sudo privileges.

              – zero_coding
              Nov 29 '17 at 8:28











            • Edited, just now

              – Yien
              Nov 29 '17 at 9:10














            1












            1








            1







            Assuming that this script doesn't need sudo privileges.



            One way to autostart a script is use a Desktop Autostarting method.



            In Ubuntu you can do it like this,




            • Create a file in .config/autostart from your home directory with an extension of .desktop


            Say you created zookeeper.desktop then open and include this format.



            For Zookeeper Entry



            [Desktop Entry]

            Type=Application

            Name=Zookeeper

            Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start


            Then create a separate one for:



            For Kafra Entry



            [Desktop Entry]

            Type=Application

            Name=kafra

            Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


            or just the script your made



            For your Script Entry



            [Desktop Entry]

            Type=Application

            Name=/name/of/your/script

            Exec=/path/to/your/script


            Then you can do it like this(sudo)



            add the path of your script to /etc/rc.local(open and edit rc.local)



            /path/to/your/script &



            exit 0



            if it doesn't exist but it your system have /etc/rc.d1 to 6
            just simply add your script inside that folder and will be executed with sudo rights.






            share|improve this answer















            Assuming that this script doesn't need sudo privileges.



            One way to autostart a script is use a Desktop Autostarting method.



            In Ubuntu you can do it like this,




            • Create a file in .config/autostart from your home directory with an extension of .desktop


            Say you created zookeeper.desktop then open and include this format.



            For Zookeeper Entry



            [Desktop Entry]

            Type=Application

            Name=Zookeeper

            Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start


            Then create a separate one for:



            For Kafra Entry



            [Desktop Entry]

            Type=Application

            Name=kafra

            Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties


            or just the script your made



            For your Script Entry



            [Desktop Entry]

            Type=Application

            Name=/name/of/your/script

            Exec=/path/to/your/script


            Then you can do it like this(sudo)



            add the path of your script to /etc/rc.local(open and edit rc.local)



            /path/to/your/script &



            exit 0



            if it doesn't exist but it your system have /etc/rc.d1 to 6
            just simply add your script inside that folder and will be executed with sudo rights.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 29 '17 at 9:03

























            answered Nov 29 '17 at 6:05









            YienYien

            1546




            1546













            • I've forgot to mentioned. The script needs sudo privileges.

              – zero_coding
              Nov 29 '17 at 8:28











            • Edited, just now

              – Yien
              Nov 29 '17 at 9:10



















            • I've forgot to mentioned. The script needs sudo privileges.

              – zero_coding
              Nov 29 '17 at 8:28











            • Edited, just now

              – Yien
              Nov 29 '17 at 9:10

















            I've forgot to mentioned. The script needs sudo privileges.

            – zero_coding
            Nov 29 '17 at 8:28





            I've forgot to mentioned. The script needs sudo privileges.

            – zero_coding
            Nov 29 '17 at 8:28













            Edited, just now

            – Yien
            Nov 29 '17 at 9:10





            Edited, just now

            – Yien
            Nov 29 '17 at 9:10













            0














            A variant of the approach described above is to modify the Exec command in the .desktop file as follows:



                Exec=gnome-terminal -- /path/to/your/script.sh start


            This has two advantages




            1. You can store your script anywhere you like without having to modify anything in rc.local or /etc

            2. You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.






            share|improve this answer




























              0














              A variant of the approach described above is to modify the Exec command in the .desktop file as follows:



                  Exec=gnome-terminal -- /path/to/your/script.sh start


              This has two advantages




              1. You can store your script anywhere you like without having to modify anything in rc.local or /etc

              2. You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.






              share|improve this answer


























                0












                0








                0







                A variant of the approach described above is to modify the Exec command in the .desktop file as follows:



                    Exec=gnome-terminal -- /path/to/your/script.sh start


                This has two advantages




                1. You can store your script anywhere you like without having to modify anything in rc.local or /etc

                2. You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.






                share|improve this answer













                A variant of the approach described above is to modify the Exec command in the .desktop file as follows:



                    Exec=gnome-terminal -- /path/to/your/script.sh start


                This has two advantages




                1. You can store your script anywhere you like without having to modify anything in rc.local or /etc

                2. You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 16 at 10:53









                Turbo ReynoldsTurbo Reynolds

                11




                11






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • 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%2faskubuntu.com%2fquestions%2f981047%2fhow-to-write-a-startup-script%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 make a Squid Proxy server?

                    Is this a new Fibonacci Identity?

                    19世紀