make an application startup automaticallyWhere to put the script file for autostartHow to start an...

Why does the `ls` command sort files like this?

Count the number of triangles

Can a network vulnerability be exploited locally?

Why is the Grievance Studies affair considered to be research requiring IRB approval?

To what extent should we fear giving offense?

Why did Lucius make a deal out of Buckbeak hurting Draco but not about Draco being turned into a ferret?

What checks exist against overuse of presidential pardons in the USA?

Pen test results for web application include a file from a forbidden directory that is not even used or referenced

Why does Sauron not permit his followers to use his name?

Get contents before a colon

How does attacking during a conversation affect initiative?

Why does glibc's strlen need to be so complicated to run quickly?

What should be done with the carbon when using magic to get oxygen from carbon dioxide?

What does GDPR mean to myself regarding my own data?

Coupling two 15 Amp circuit breaker for 20 Amp

How do Barton (Hawkeye/Ronin) and Romanov (Black Widow) end up on the Benatar on Morag in 2014?

Does the Tribal card type have inherent mechanical implications?

Drawing probabilities on a simplex in TikZ

Term used to describe a person who predicts future outcomes

Why might one *not* want to use a capo?

Is this password scheme legit?

What ways are there to "PEEK" memory sections in (different) BASIC(s)

Why can't I identify major and minor chords?

web scraping images



make an application startup automatically


Where to put the script file for autostartHow to start an application automatically on bootiSCSI on startupfstab does not mount cifs at startupDedicated-purpose, single application linux boxesDisable Touchpad automatically at startupHow to start GUI application with upstart?Automatically run certain scripts at first login/PC startupHow to start the upstart process for golang application?Running Application Automatiacallycentos - Remove penguin logo at startup






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







3















Here I have an application deployed to linux, I want the app to startup automatically when the linux start up. I'm using an command like 'sudo ./start' to start the application.
How Can I do that?



OS: CentOS 6










share|improve this question

































    3















    Here I have an application deployed to linux, I want the app to startup automatically when the linux start up. I'm using an command like 'sudo ./start' to start the application.
    How Can I do that?



    OS: CentOS 6










    share|improve this question





























      3












      3








      3


      1






      Here I have an application deployed to linux, I want the app to startup automatically when the linux start up. I'm using an command like 'sudo ./start' to start the application.
      How Can I do that?



      OS: CentOS 6










      share|improve this question
















      Here I have an application deployed to linux, I want the app to startup automatically when the linux start up. I'm using an command like 'sudo ./start' to start the application.
      How Can I do that?



      OS: CentOS 6







      linux centos






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 19:54









      Rui F Ribeiro

      41.3k16 gold badges94 silver badges158 bronze badges




      41.3k16 gold badges94 silver badges158 bronze badges










      asked Aug 29 '14 at 2:52









      user3231931user3231931

      161 gold badge1 silver badge2 bronze badges




      161 gold badge1 silver badge2 bronze badges

























          3 Answers
          3






          active

          oldest

          votes


















          8















          I cannot recommend to add things in /etc/rc.local. It's a relict of old unix days. There are Linuxes who no longer support rc.local.



          However, It may start your application/service correctly, but it never shuts your process down gracefully.



          It's better to use the systems own mechanism of init scripts (Systemd, Upstart, ...). I would write an rc script that looks like this (there might be a skeleton/template on your system in /etc/init.d/skeleton):



          #!/bin/bash
          . /etc/init.d/functions

          start() {
          echo -n "Starting <servicename>: "
          #/path/to/the/executable/of/your/application
          }

          stop() {
          echo -n "Shutting down <servicename>: "
          #command_to_gracefully_end_the_application
          }

          case "$1" in
          start)
          start
          ;;
          stop)
          stop
          ;;
          status)
          #command_to_report_the_status
          ;;
          restart)
          stop
          start
          ;;
          *)
          echo "Usage: <servicename> {start|stop|restart}"
          exit 1
          ;;
          esac
          exit $?


          Place your script in /etc/init.d/, make it executable and add it to the system runlevels 3, 4 and 5:



          chkconfig --level 345 <servicename> on


          Also you can manually start and stop it with:



          service <servicename> start
          service <servicename> stop





          share|improve this answer


























          • It's a good idea to write a script like this, can I can manually start and stop. but when reboot my computer, the application cannot start up. why?

            – user3231931
            Aug 29 '14 at 7:36













          • I've resolved this issue after clueless tries.

            – user3231931
            Aug 29 '14 at 8:04











          • It seems that to make the file supported by chkconfig, a few additional lines of comments need to be added: serverfault.com/questions/29788/…

            – xji
            Sep 6 '18 at 13:52



















          2















          Most Linuxes out there run /etc/rc.local once at system boot-up. Open this file with an editor and add the command to start your application.



          No need to prefix sudo to the command as the script is run as root.



          Be sure to add a '&` (ampersand) at the end of the command to run it in the background so it doesn't hold up your system from booting in case your application doesn't finish in one go.



          Example to execute the file myscript located in /usr/local/bin/



          # place near the end of /etc/rc.local
          /usr/local/bin/myscript &





          share|improve this answer



































            0
















            Using cron worked for me.




            # enter crontab edit
            crontab -e

            # place this inside the cron file you opened with the previous command
            @reboot /path/to/your/script.sh





            share|improve this answer








            New contributor



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
























              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
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f152716%2fmake-an-application-startup-automatically%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              8















              I cannot recommend to add things in /etc/rc.local. It's a relict of old unix days. There are Linuxes who no longer support rc.local.



              However, It may start your application/service correctly, but it never shuts your process down gracefully.



              It's better to use the systems own mechanism of init scripts (Systemd, Upstart, ...). I would write an rc script that looks like this (there might be a skeleton/template on your system in /etc/init.d/skeleton):



              #!/bin/bash
              . /etc/init.d/functions

              start() {
              echo -n "Starting <servicename>: "
              #/path/to/the/executable/of/your/application
              }

              stop() {
              echo -n "Shutting down <servicename>: "
              #command_to_gracefully_end_the_application
              }

              case "$1" in
              start)
              start
              ;;
              stop)
              stop
              ;;
              status)
              #command_to_report_the_status
              ;;
              restart)
              stop
              start
              ;;
              *)
              echo "Usage: <servicename> {start|stop|restart}"
              exit 1
              ;;
              esac
              exit $?


              Place your script in /etc/init.d/, make it executable and add it to the system runlevels 3, 4 and 5:



              chkconfig --level 345 <servicename> on


              Also you can manually start and stop it with:



              service <servicename> start
              service <servicename> stop





              share|improve this answer


























              • It's a good idea to write a script like this, can I can manually start and stop. but when reboot my computer, the application cannot start up. why?

                – user3231931
                Aug 29 '14 at 7:36













              • I've resolved this issue after clueless tries.

                – user3231931
                Aug 29 '14 at 8:04











              • It seems that to make the file supported by chkconfig, a few additional lines of comments need to be added: serverfault.com/questions/29788/…

                – xji
                Sep 6 '18 at 13:52
















              8















              I cannot recommend to add things in /etc/rc.local. It's a relict of old unix days. There are Linuxes who no longer support rc.local.



              However, It may start your application/service correctly, but it never shuts your process down gracefully.



              It's better to use the systems own mechanism of init scripts (Systemd, Upstart, ...). I would write an rc script that looks like this (there might be a skeleton/template on your system in /etc/init.d/skeleton):



              #!/bin/bash
              . /etc/init.d/functions

              start() {
              echo -n "Starting <servicename>: "
              #/path/to/the/executable/of/your/application
              }

              stop() {
              echo -n "Shutting down <servicename>: "
              #command_to_gracefully_end_the_application
              }

              case "$1" in
              start)
              start
              ;;
              stop)
              stop
              ;;
              status)
              #command_to_report_the_status
              ;;
              restart)
              stop
              start
              ;;
              *)
              echo "Usage: <servicename> {start|stop|restart}"
              exit 1
              ;;
              esac
              exit $?


              Place your script in /etc/init.d/, make it executable and add it to the system runlevels 3, 4 and 5:



              chkconfig --level 345 <servicename> on


              Also you can manually start and stop it with:



              service <servicename> start
              service <servicename> stop





              share|improve this answer


























              • It's a good idea to write a script like this, can I can manually start and stop. but when reboot my computer, the application cannot start up. why?

                – user3231931
                Aug 29 '14 at 7:36













              • I've resolved this issue after clueless tries.

                – user3231931
                Aug 29 '14 at 8:04











              • It seems that to make the file supported by chkconfig, a few additional lines of comments need to be added: serverfault.com/questions/29788/…

                – xji
                Sep 6 '18 at 13:52














              8














              8










              8









              I cannot recommend to add things in /etc/rc.local. It's a relict of old unix days. There are Linuxes who no longer support rc.local.



              However, It may start your application/service correctly, but it never shuts your process down gracefully.



              It's better to use the systems own mechanism of init scripts (Systemd, Upstart, ...). I would write an rc script that looks like this (there might be a skeleton/template on your system in /etc/init.d/skeleton):



              #!/bin/bash
              . /etc/init.d/functions

              start() {
              echo -n "Starting <servicename>: "
              #/path/to/the/executable/of/your/application
              }

              stop() {
              echo -n "Shutting down <servicename>: "
              #command_to_gracefully_end_the_application
              }

              case "$1" in
              start)
              start
              ;;
              stop)
              stop
              ;;
              status)
              #command_to_report_the_status
              ;;
              restart)
              stop
              start
              ;;
              *)
              echo "Usage: <servicename> {start|stop|restart}"
              exit 1
              ;;
              esac
              exit $?


              Place your script in /etc/init.d/, make it executable and add it to the system runlevels 3, 4 and 5:



              chkconfig --level 345 <servicename> on


              Also you can manually start and stop it with:



              service <servicename> start
              service <servicename> stop





              share|improve this answer













              I cannot recommend to add things in /etc/rc.local. It's a relict of old unix days. There are Linuxes who no longer support rc.local.



              However, It may start your application/service correctly, but it never shuts your process down gracefully.



              It's better to use the systems own mechanism of init scripts (Systemd, Upstart, ...). I would write an rc script that looks like this (there might be a skeleton/template on your system in /etc/init.d/skeleton):



              #!/bin/bash
              . /etc/init.d/functions

              start() {
              echo -n "Starting <servicename>: "
              #/path/to/the/executable/of/your/application
              }

              stop() {
              echo -n "Shutting down <servicename>: "
              #command_to_gracefully_end_the_application
              }

              case "$1" in
              start)
              start
              ;;
              stop)
              stop
              ;;
              status)
              #command_to_report_the_status
              ;;
              restart)
              stop
              start
              ;;
              *)
              echo "Usage: <servicename> {start|stop|restart}"
              exit 1
              ;;
              esac
              exit $?


              Place your script in /etc/init.d/, make it executable and add it to the system runlevels 3, 4 and 5:



              chkconfig --level 345 <servicename> on


              Also you can manually start and stop it with:



              service <servicename> start
              service <servicename> stop






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Aug 29 '14 at 6:29









              chaoschaos

              37.4k9 gold badges83 silver badges123 bronze badges




              37.4k9 gold badges83 silver badges123 bronze badges
















              • It's a good idea to write a script like this, can I can manually start and stop. but when reboot my computer, the application cannot start up. why?

                – user3231931
                Aug 29 '14 at 7:36













              • I've resolved this issue after clueless tries.

                – user3231931
                Aug 29 '14 at 8:04











              • It seems that to make the file supported by chkconfig, a few additional lines of comments need to be added: serverfault.com/questions/29788/…

                – xji
                Sep 6 '18 at 13:52



















              • It's a good idea to write a script like this, can I can manually start and stop. but when reboot my computer, the application cannot start up. why?

                – user3231931
                Aug 29 '14 at 7:36













              • I've resolved this issue after clueless tries.

                – user3231931
                Aug 29 '14 at 8:04











              • It seems that to make the file supported by chkconfig, a few additional lines of comments need to be added: serverfault.com/questions/29788/…

                – xji
                Sep 6 '18 at 13:52

















              It's a good idea to write a script like this, can I can manually start and stop. but when reboot my computer, the application cannot start up. why?

              – user3231931
              Aug 29 '14 at 7:36







              It's a good idea to write a script like this, can I can manually start and stop. but when reboot my computer, the application cannot start up. why?

              – user3231931
              Aug 29 '14 at 7:36















              I've resolved this issue after clueless tries.

              – user3231931
              Aug 29 '14 at 8:04





              I've resolved this issue after clueless tries.

              – user3231931
              Aug 29 '14 at 8:04













              It seems that to make the file supported by chkconfig, a few additional lines of comments need to be added: serverfault.com/questions/29788/…

              – xji
              Sep 6 '18 at 13:52





              It seems that to make the file supported by chkconfig, a few additional lines of comments need to be added: serverfault.com/questions/29788/…

              – xji
              Sep 6 '18 at 13:52













              2















              Most Linuxes out there run /etc/rc.local once at system boot-up. Open this file with an editor and add the command to start your application.



              No need to prefix sudo to the command as the script is run as root.



              Be sure to add a '&` (ampersand) at the end of the command to run it in the background so it doesn't hold up your system from booting in case your application doesn't finish in one go.



              Example to execute the file myscript located in /usr/local/bin/



              # place near the end of /etc/rc.local
              /usr/local/bin/myscript &





              share|improve this answer
































                2















                Most Linuxes out there run /etc/rc.local once at system boot-up. Open this file with an editor and add the command to start your application.



                No need to prefix sudo to the command as the script is run as root.



                Be sure to add a '&` (ampersand) at the end of the command to run it in the background so it doesn't hold up your system from booting in case your application doesn't finish in one go.



                Example to execute the file myscript located in /usr/local/bin/



                # place near the end of /etc/rc.local
                /usr/local/bin/myscript &





                share|improve this answer






























                  2














                  2










                  2









                  Most Linuxes out there run /etc/rc.local once at system boot-up. Open this file with an editor and add the command to start your application.



                  No need to prefix sudo to the command as the script is run as root.



                  Be sure to add a '&` (ampersand) at the end of the command to run it in the background so it doesn't hold up your system from booting in case your application doesn't finish in one go.



                  Example to execute the file myscript located in /usr/local/bin/



                  # place near the end of /etc/rc.local
                  /usr/local/bin/myscript &





                  share|improve this answer















                  Most Linuxes out there run /etc/rc.local once at system boot-up. Open this file with an editor and add the command to start your application.



                  No need to prefix sudo to the command as the script is run as root.



                  Be sure to add a '&` (ampersand) at the end of the command to run it in the background so it doesn't hold up your system from booting in case your application doesn't finish in one go.



                  Example to execute the file myscript located in /usr/local/bin/



                  # place near the end of /etc/rc.local
                  /usr/local/bin/myscript &






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 29 '14 at 3:21

























                  answered Aug 29 '14 at 3:16









                  captchacaptcha

                  7961 gold badge6 silver badges16 bronze badges




                  7961 gold badge6 silver badges16 bronze badges


























                      0
















                      Using cron worked for me.




                      # enter crontab edit
                      crontab -e

                      # place this inside the cron file you opened with the previous command
                      @reboot /path/to/your/script.sh





                      share|improve this answer








                      New contributor



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


























                        0
















                        Using cron worked for me.




                        # enter crontab edit
                        crontab -e

                        # place this inside the cron file you opened with the previous command
                        @reboot /path/to/your/script.sh





                        share|improve this answer








                        New contributor



                        kintsukuroi 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










                          Using cron worked for me.




                          # enter crontab edit
                          crontab -e

                          # place this inside the cron file you opened with the previous command
                          @reboot /path/to/your/script.sh





                          share|improve this answer








                          New contributor



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










                          Using cron worked for me.




                          # enter crontab edit
                          crontab -e

                          # place this inside the cron file you opened with the previous command
                          @reboot /path/to/your/script.sh






                          share|improve this answer








                          New contributor



                          kintsukuroi 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 answer



                          share|improve this answer






                          New contributor



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








                          answered 44 mins ago









                          kintsukuroikintsukuroi

                          1




                          1




                          New contributor



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




                          New contributor




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



































                              draft saved

                              draft discarded




















































                              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.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f152716%2fmake-an-application-startup-automatically%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

                              Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

                              The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

                              Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...