How to start a script file on boot?












7














I am running a little minecraft server.



I want Lubuntu to execute the following script when the server boots up. NOT on login, and NOT on restart (unless it's starting up of course).



The script is currently located in:



/home/mc/server/craftbukkit.sh


I can manually launch the script by just going into the dir and typing ./craftbukkit.sh. But I want to fire off the script when the machine boots.










share|improve this question
























  • Is that a daemon or onetime script ?
    – daisy
    Aug 7 '12 at 5:58










  • @warl0ck: daemon. craftbukkit is the name of the server, and includes a shell script for executing it as it's a java application.
    – Matthew Scharley
    Aug 7 '12 at 6:20
















7














I am running a little minecraft server.



I want Lubuntu to execute the following script when the server boots up. NOT on login, and NOT on restart (unless it's starting up of course).



The script is currently located in:



/home/mc/server/craftbukkit.sh


I can manually launch the script by just going into the dir and typing ./craftbukkit.sh. But I want to fire off the script when the machine boots.










share|improve this question
























  • Is that a daemon or onetime script ?
    – daisy
    Aug 7 '12 at 5:58










  • @warl0ck: daemon. craftbukkit is the name of the server, and includes a shell script for executing it as it's a java application.
    – Matthew Scharley
    Aug 7 '12 at 6:20














7












7








7


1





I am running a little minecraft server.



I want Lubuntu to execute the following script when the server boots up. NOT on login, and NOT on restart (unless it's starting up of course).



The script is currently located in:



/home/mc/server/craftbukkit.sh


I can manually launch the script by just going into the dir and typing ./craftbukkit.sh. But I want to fire off the script when the machine boots.










share|improve this question















I am running a little minecraft server.



I want Lubuntu to execute the following script when the server boots up. NOT on login, and NOT on restart (unless it's starting up of course).



The script is currently located in:



/home/mc/server/craftbukkit.sh


I can manually launch the script by just going into the dir and typing ./craftbukkit.sh. But I want to fire off the script when the machine boots.







startup services






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Rui F Ribeiro

38.8k1479128




38.8k1479128










asked Aug 7 '12 at 3:09









John Palmer

38113




38113












  • Is that a daemon or onetime script ?
    – daisy
    Aug 7 '12 at 5:58










  • @warl0ck: daemon. craftbukkit is the name of the server, and includes a shell script for executing it as it's a java application.
    – Matthew Scharley
    Aug 7 '12 at 6:20


















  • Is that a daemon or onetime script ?
    – daisy
    Aug 7 '12 at 5:58










  • @warl0ck: daemon. craftbukkit is the name of the server, and includes a shell script for executing it as it's a java application.
    – Matthew Scharley
    Aug 7 '12 at 6:20
















Is that a daemon or onetime script ?
– daisy
Aug 7 '12 at 5:58




Is that a daemon or onetime script ?
– daisy
Aug 7 '12 at 5:58












@warl0ck: daemon. craftbukkit is the name of the server, and includes a shell script for executing it as it's a java application.
– Matthew Scharley
Aug 7 '12 at 6:20




@warl0ck: daemon. craftbukkit is the name of the server, and includes a shell script for executing it as it's a java application.
– Matthew Scharley
Aug 7 '12 at 6:20










4 Answers
4






active

oldest

votes


















5














I run a minecraft server from a debian terminal, and this is probably the wrong way to do it, but it works. First, sudo apt-get install screen, then save the following script as /etc/init.d/minecraft:



#!/bin/bash
case "$1" in
start)
screen -S minecraft /home/mc/server/craftbukkit.sh
echo "Server started on screen minecraft"
;;
stop)
screen -X -S minecraft kill
echo "Server shutting down"
;;
*)
echo "Usage: /etc/init.d/minecraft {start|stop}"
exit 1
;;
esac

exit 0


Now, run the following commands as root:



update-rc.d -f minecraft defaults



This will make the minecraft server run in the background when the system boots. To view the console, run screen -x minecraft in a terminal. To quit the console, press Ctrl+A and then D.






share|improve this answer























  • If this fails you, you can clean up by removing the following files: /etc/init.d/minecraft /etc/rc0.d/K01minecraft /etc/rc1.d/K01minecraft /etc/rc2.d/S01minecraft /etc/rc3.d/S01minecraft /etc/rc4.d/S01minecraft /etc/rc5.d/S01minecraft /etc/rc6.d/K01minecraft /etc/rcS.d/S01minecraft
    – Suchipi
    Aug 7 '12 at 4:55












  • I'm sure there's an easier way to setup the symlinks, but I haven't used ubuntu in a while. This is the right approach though.
    – Matthew Scharley
    Aug 7 '12 at 6:19










  • @MatthewScharley update-rc.d is the right way to do with old-style init scripts
    – daisy
    Aug 7 '12 at 6:28










  • Sometimes update-rc.d complains about this init script, but I didn't know about the -f option. Thanks, @warl0ck
    – Suchipi
    Aug 7 '12 at 6:32






  • 1




    @ppumkin init.d scripts are run as root. When I used this in the past on my own minecraft server, everything lived in /root/minecraft.
    – Suchipi
    Oct 15 '13 at 1:20



















6














On latest Ubuntu, you should do it like this, create /etc/init/bukkit.conf (whatever .conf),



description     "Some java server"
author "Moi <moi@x.com>"

start on runlevel [2345] # change start / stop level if needed
stop on runlevel [016]

pre-start script
echo "script is abort to start"
end script

exec /path/to/script param1 param2

post-start script
echo "script is started" # if you needed any post-start hack
end script


More information here.






share|improve this answer





























    0














    in ubuntu/lubuntu there should be a menu item called "startup applications". On my ubuntu server it is under the 'system > preferences > startup applications' menu. That is in gnome but it should be smiler. Choose the add button and give it a name like minecraft and make sure the box it checked for it to start.



    this may not be a hard core linux solution but it provides an easy way to see if it is enabled and to disable/enable it when you want to.






    share|improve this answer





















    • Unfortunately, this does not start the script at boot, only when you log in.
      – daniel kullmann
      Aug 7 '12 at 7:11










    • true but was going for a simplistic response as usually do when it comes to ubuntu variants or as I call them windows of the Linux world.
      – Joe
      Aug 7 '12 at 7:15



















    0














    Docker I prefer to create Dockerfile and run it with --restart=always tag



    If you want to run your shell script on boot
    Then use unix's crontab It's very easy to use & you can configure in minutes





    1. Edit crontab run the following replacing the "USER" with your desired runtime user for the node process. If you choose a different user other than yourself, you will have to run this with sudo.



      $ crontab -u USER -e




    2. Once in the editor add the following line:



      @reboot sh /home/mc/server/craftbukkit.sh




    3. Save & confirm file is saved by check command of #1 again



      Note: In my opinion, you should use the full path in crontab file to prevent issues




    You can refer this URL reference
    Ubuntu Cron HowTo






    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',
      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%2f44903%2fhow-to-start-a-script-file-on-boot%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5














      I run a minecraft server from a debian terminal, and this is probably the wrong way to do it, but it works. First, sudo apt-get install screen, then save the following script as /etc/init.d/minecraft:



      #!/bin/bash
      case "$1" in
      start)
      screen -S minecraft /home/mc/server/craftbukkit.sh
      echo "Server started on screen minecraft"
      ;;
      stop)
      screen -X -S minecraft kill
      echo "Server shutting down"
      ;;
      *)
      echo "Usage: /etc/init.d/minecraft {start|stop}"
      exit 1
      ;;
      esac

      exit 0


      Now, run the following commands as root:



      update-rc.d -f minecraft defaults



      This will make the minecraft server run in the background when the system boots. To view the console, run screen -x minecraft in a terminal. To quit the console, press Ctrl+A and then D.






      share|improve this answer























      • If this fails you, you can clean up by removing the following files: /etc/init.d/minecraft /etc/rc0.d/K01minecraft /etc/rc1.d/K01minecraft /etc/rc2.d/S01minecraft /etc/rc3.d/S01minecraft /etc/rc4.d/S01minecraft /etc/rc5.d/S01minecraft /etc/rc6.d/K01minecraft /etc/rcS.d/S01minecraft
        – Suchipi
        Aug 7 '12 at 4:55












      • I'm sure there's an easier way to setup the symlinks, but I haven't used ubuntu in a while. This is the right approach though.
        – Matthew Scharley
        Aug 7 '12 at 6:19










      • @MatthewScharley update-rc.d is the right way to do with old-style init scripts
        – daisy
        Aug 7 '12 at 6:28










      • Sometimes update-rc.d complains about this init script, but I didn't know about the -f option. Thanks, @warl0ck
        – Suchipi
        Aug 7 '12 at 6:32






      • 1




        @ppumkin init.d scripts are run as root. When I used this in the past on my own minecraft server, everything lived in /root/minecraft.
        – Suchipi
        Oct 15 '13 at 1:20
















      5














      I run a minecraft server from a debian terminal, and this is probably the wrong way to do it, but it works. First, sudo apt-get install screen, then save the following script as /etc/init.d/minecraft:



      #!/bin/bash
      case "$1" in
      start)
      screen -S minecraft /home/mc/server/craftbukkit.sh
      echo "Server started on screen minecraft"
      ;;
      stop)
      screen -X -S minecraft kill
      echo "Server shutting down"
      ;;
      *)
      echo "Usage: /etc/init.d/minecraft {start|stop}"
      exit 1
      ;;
      esac

      exit 0


      Now, run the following commands as root:



      update-rc.d -f minecraft defaults



      This will make the minecraft server run in the background when the system boots. To view the console, run screen -x minecraft in a terminal. To quit the console, press Ctrl+A and then D.






      share|improve this answer























      • If this fails you, you can clean up by removing the following files: /etc/init.d/minecraft /etc/rc0.d/K01minecraft /etc/rc1.d/K01minecraft /etc/rc2.d/S01minecraft /etc/rc3.d/S01minecraft /etc/rc4.d/S01minecraft /etc/rc5.d/S01minecraft /etc/rc6.d/K01minecraft /etc/rcS.d/S01minecraft
        – Suchipi
        Aug 7 '12 at 4:55












      • I'm sure there's an easier way to setup the symlinks, but I haven't used ubuntu in a while. This is the right approach though.
        – Matthew Scharley
        Aug 7 '12 at 6:19










      • @MatthewScharley update-rc.d is the right way to do with old-style init scripts
        – daisy
        Aug 7 '12 at 6:28










      • Sometimes update-rc.d complains about this init script, but I didn't know about the -f option. Thanks, @warl0ck
        – Suchipi
        Aug 7 '12 at 6:32






      • 1




        @ppumkin init.d scripts are run as root. When I used this in the past on my own minecraft server, everything lived in /root/minecraft.
        – Suchipi
        Oct 15 '13 at 1:20














      5












      5








      5






      I run a minecraft server from a debian terminal, and this is probably the wrong way to do it, but it works. First, sudo apt-get install screen, then save the following script as /etc/init.d/minecraft:



      #!/bin/bash
      case "$1" in
      start)
      screen -S minecraft /home/mc/server/craftbukkit.sh
      echo "Server started on screen minecraft"
      ;;
      stop)
      screen -X -S minecraft kill
      echo "Server shutting down"
      ;;
      *)
      echo "Usage: /etc/init.d/minecraft {start|stop}"
      exit 1
      ;;
      esac

      exit 0


      Now, run the following commands as root:



      update-rc.d -f minecraft defaults



      This will make the minecraft server run in the background when the system boots. To view the console, run screen -x minecraft in a terminal. To quit the console, press Ctrl+A and then D.






      share|improve this answer














      I run a minecraft server from a debian terminal, and this is probably the wrong way to do it, but it works. First, sudo apt-get install screen, then save the following script as /etc/init.d/minecraft:



      #!/bin/bash
      case "$1" in
      start)
      screen -S minecraft /home/mc/server/craftbukkit.sh
      echo "Server started on screen minecraft"
      ;;
      stop)
      screen -X -S minecraft kill
      echo "Server shutting down"
      ;;
      *)
      echo "Usage: /etc/init.d/minecraft {start|stop}"
      exit 1
      ;;
      esac

      exit 0


      Now, run the following commands as root:



      update-rc.d -f minecraft defaults



      This will make the minecraft server run in the background when the system boots. To view the console, run screen -x minecraft in a terminal. To quit the console, press Ctrl+A and then D.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Aug 7 '12 at 6:27









      daisy

      28.3k48167300




      28.3k48167300










      answered Aug 7 '12 at 4:51









      Suchipi

      8043714




      8043714












      • If this fails you, you can clean up by removing the following files: /etc/init.d/minecraft /etc/rc0.d/K01minecraft /etc/rc1.d/K01minecraft /etc/rc2.d/S01minecraft /etc/rc3.d/S01minecraft /etc/rc4.d/S01minecraft /etc/rc5.d/S01minecraft /etc/rc6.d/K01minecraft /etc/rcS.d/S01minecraft
        – Suchipi
        Aug 7 '12 at 4:55












      • I'm sure there's an easier way to setup the symlinks, but I haven't used ubuntu in a while. This is the right approach though.
        – Matthew Scharley
        Aug 7 '12 at 6:19










      • @MatthewScharley update-rc.d is the right way to do with old-style init scripts
        – daisy
        Aug 7 '12 at 6:28










      • Sometimes update-rc.d complains about this init script, but I didn't know about the -f option. Thanks, @warl0ck
        – Suchipi
        Aug 7 '12 at 6:32






      • 1




        @ppumkin init.d scripts are run as root. When I used this in the past on my own minecraft server, everything lived in /root/minecraft.
        – Suchipi
        Oct 15 '13 at 1:20


















      • If this fails you, you can clean up by removing the following files: /etc/init.d/minecraft /etc/rc0.d/K01minecraft /etc/rc1.d/K01minecraft /etc/rc2.d/S01minecraft /etc/rc3.d/S01minecraft /etc/rc4.d/S01minecraft /etc/rc5.d/S01minecraft /etc/rc6.d/K01minecraft /etc/rcS.d/S01minecraft
        – Suchipi
        Aug 7 '12 at 4:55












      • I'm sure there's an easier way to setup the symlinks, but I haven't used ubuntu in a while. This is the right approach though.
        – Matthew Scharley
        Aug 7 '12 at 6:19










      • @MatthewScharley update-rc.d is the right way to do with old-style init scripts
        – daisy
        Aug 7 '12 at 6:28










      • Sometimes update-rc.d complains about this init script, but I didn't know about the -f option. Thanks, @warl0ck
        – Suchipi
        Aug 7 '12 at 6:32






      • 1




        @ppumkin init.d scripts are run as root. When I used this in the past on my own minecraft server, everything lived in /root/minecraft.
        – Suchipi
        Oct 15 '13 at 1:20
















      If this fails you, you can clean up by removing the following files: /etc/init.d/minecraft /etc/rc0.d/K01minecraft /etc/rc1.d/K01minecraft /etc/rc2.d/S01minecraft /etc/rc3.d/S01minecraft /etc/rc4.d/S01minecraft /etc/rc5.d/S01minecraft /etc/rc6.d/K01minecraft /etc/rcS.d/S01minecraft
      – Suchipi
      Aug 7 '12 at 4:55






      If this fails you, you can clean up by removing the following files: /etc/init.d/minecraft /etc/rc0.d/K01minecraft /etc/rc1.d/K01minecraft /etc/rc2.d/S01minecraft /etc/rc3.d/S01minecraft /etc/rc4.d/S01minecraft /etc/rc5.d/S01minecraft /etc/rc6.d/K01minecraft /etc/rcS.d/S01minecraft
      – Suchipi
      Aug 7 '12 at 4:55














      I'm sure there's an easier way to setup the symlinks, but I haven't used ubuntu in a while. This is the right approach though.
      – Matthew Scharley
      Aug 7 '12 at 6:19




      I'm sure there's an easier way to setup the symlinks, but I haven't used ubuntu in a while. This is the right approach though.
      – Matthew Scharley
      Aug 7 '12 at 6:19












      @MatthewScharley update-rc.d is the right way to do with old-style init scripts
      – daisy
      Aug 7 '12 at 6:28




      @MatthewScharley update-rc.d is the right way to do with old-style init scripts
      – daisy
      Aug 7 '12 at 6:28












      Sometimes update-rc.d complains about this init script, but I didn't know about the -f option. Thanks, @warl0ck
      – Suchipi
      Aug 7 '12 at 6:32




      Sometimes update-rc.d complains about this init script, but I didn't know about the -f option. Thanks, @warl0ck
      – Suchipi
      Aug 7 '12 at 6:32




      1




      1




      @ppumkin init.d scripts are run as root. When I used this in the past on my own minecraft server, everything lived in /root/minecraft.
      – Suchipi
      Oct 15 '13 at 1:20




      @ppumkin init.d scripts are run as root. When I used this in the past on my own minecraft server, everything lived in /root/minecraft.
      – Suchipi
      Oct 15 '13 at 1:20













      6














      On latest Ubuntu, you should do it like this, create /etc/init/bukkit.conf (whatever .conf),



      description     "Some java server"
      author "Moi <moi@x.com>"

      start on runlevel [2345] # change start / stop level if needed
      stop on runlevel [016]

      pre-start script
      echo "script is abort to start"
      end script

      exec /path/to/script param1 param2

      post-start script
      echo "script is started" # if you needed any post-start hack
      end script


      More information here.






      share|improve this answer


























        6














        On latest Ubuntu, you should do it like this, create /etc/init/bukkit.conf (whatever .conf),



        description     "Some java server"
        author "Moi <moi@x.com>"

        start on runlevel [2345] # change start / stop level if needed
        stop on runlevel [016]

        pre-start script
        echo "script is abort to start"
        end script

        exec /path/to/script param1 param2

        post-start script
        echo "script is started" # if you needed any post-start hack
        end script


        More information here.






        share|improve this answer
























          6












          6








          6






          On latest Ubuntu, you should do it like this, create /etc/init/bukkit.conf (whatever .conf),



          description     "Some java server"
          author "Moi <moi@x.com>"

          start on runlevel [2345] # change start / stop level if needed
          stop on runlevel [016]

          pre-start script
          echo "script is abort to start"
          end script

          exec /path/to/script param1 param2

          post-start script
          echo "script is started" # if you needed any post-start hack
          end script


          More information here.






          share|improve this answer












          On latest Ubuntu, you should do it like this, create /etc/init/bukkit.conf (whatever .conf),



          description     "Some java server"
          author "Moi <moi@x.com>"

          start on runlevel [2345] # change start / stop level if needed
          stop on runlevel [016]

          pre-start script
          echo "script is abort to start"
          end script

          exec /path/to/script param1 param2

          post-start script
          echo "script is started" # if you needed any post-start hack
          end script


          More information here.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 7 '12 at 6:26









          daisy

          28.3k48167300




          28.3k48167300























              0














              in ubuntu/lubuntu there should be a menu item called "startup applications". On my ubuntu server it is under the 'system > preferences > startup applications' menu. That is in gnome but it should be smiler. Choose the add button and give it a name like minecraft and make sure the box it checked for it to start.



              this may not be a hard core linux solution but it provides an easy way to see if it is enabled and to disable/enable it when you want to.






              share|improve this answer





















              • Unfortunately, this does not start the script at boot, only when you log in.
                – daniel kullmann
                Aug 7 '12 at 7:11










              • true but was going for a simplistic response as usually do when it comes to ubuntu variants or as I call them windows of the Linux world.
                – Joe
                Aug 7 '12 at 7:15
















              0














              in ubuntu/lubuntu there should be a menu item called "startup applications". On my ubuntu server it is under the 'system > preferences > startup applications' menu. That is in gnome but it should be smiler. Choose the add button and give it a name like minecraft and make sure the box it checked for it to start.



              this may not be a hard core linux solution but it provides an easy way to see if it is enabled and to disable/enable it when you want to.






              share|improve this answer





















              • Unfortunately, this does not start the script at boot, only when you log in.
                – daniel kullmann
                Aug 7 '12 at 7:11










              • true but was going for a simplistic response as usually do when it comes to ubuntu variants or as I call them windows of the Linux world.
                – Joe
                Aug 7 '12 at 7:15














              0












              0








              0






              in ubuntu/lubuntu there should be a menu item called "startup applications". On my ubuntu server it is under the 'system > preferences > startup applications' menu. That is in gnome but it should be smiler. Choose the add button and give it a name like minecraft and make sure the box it checked for it to start.



              this may not be a hard core linux solution but it provides an easy way to see if it is enabled and to disable/enable it when you want to.






              share|improve this answer












              in ubuntu/lubuntu there should be a menu item called "startup applications". On my ubuntu server it is under the 'system > preferences > startup applications' menu. That is in gnome but it should be smiler. Choose the add button and give it a name like minecraft and make sure the box it checked for it to start.



              this may not be a hard core linux solution but it provides an easy way to see if it is enabled and to disable/enable it when you want to.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Aug 7 '12 at 3:29









              Joe

              926414




              926414












              • Unfortunately, this does not start the script at boot, only when you log in.
                – daniel kullmann
                Aug 7 '12 at 7:11










              • true but was going for a simplistic response as usually do when it comes to ubuntu variants or as I call them windows of the Linux world.
                – Joe
                Aug 7 '12 at 7:15


















              • Unfortunately, this does not start the script at boot, only when you log in.
                – daniel kullmann
                Aug 7 '12 at 7:11










              • true but was going for a simplistic response as usually do when it comes to ubuntu variants or as I call them windows of the Linux world.
                – Joe
                Aug 7 '12 at 7:15
















              Unfortunately, this does not start the script at boot, only when you log in.
              – daniel kullmann
              Aug 7 '12 at 7:11




              Unfortunately, this does not start the script at boot, only when you log in.
              – daniel kullmann
              Aug 7 '12 at 7:11












              true but was going for a simplistic response as usually do when it comes to ubuntu variants or as I call them windows of the Linux world.
              – Joe
              Aug 7 '12 at 7:15




              true but was going for a simplistic response as usually do when it comes to ubuntu variants or as I call them windows of the Linux world.
              – Joe
              Aug 7 '12 at 7:15











              0














              Docker I prefer to create Dockerfile and run it with --restart=always tag



              If you want to run your shell script on boot
              Then use unix's crontab It's very easy to use & you can configure in minutes





              1. Edit crontab run the following replacing the "USER" with your desired runtime user for the node process. If you choose a different user other than yourself, you will have to run this with sudo.



                $ crontab -u USER -e




              2. Once in the editor add the following line:



                @reboot sh /home/mc/server/craftbukkit.sh




              3. Save & confirm file is saved by check command of #1 again



                Note: In my opinion, you should use the full path in crontab file to prevent issues




              You can refer this URL reference
              Ubuntu Cron HowTo






              share|improve this answer


























                0














                Docker I prefer to create Dockerfile and run it with --restart=always tag



                If you want to run your shell script on boot
                Then use unix's crontab It's very easy to use & you can configure in minutes





                1. Edit crontab run the following replacing the "USER" with your desired runtime user for the node process. If you choose a different user other than yourself, you will have to run this with sudo.



                  $ crontab -u USER -e




                2. Once in the editor add the following line:



                  @reboot sh /home/mc/server/craftbukkit.sh




                3. Save & confirm file is saved by check command of #1 again



                  Note: In my opinion, you should use the full path in crontab file to prevent issues




                You can refer this URL reference
                Ubuntu Cron HowTo






                share|improve this answer
























                  0












                  0








                  0






                  Docker I prefer to create Dockerfile and run it with --restart=always tag



                  If you want to run your shell script on boot
                  Then use unix's crontab It's very easy to use & you can configure in minutes





                  1. Edit crontab run the following replacing the "USER" with your desired runtime user for the node process. If you choose a different user other than yourself, you will have to run this with sudo.



                    $ crontab -u USER -e




                  2. Once in the editor add the following line:



                    @reboot sh /home/mc/server/craftbukkit.sh




                  3. Save & confirm file is saved by check command of #1 again



                    Note: In my opinion, you should use the full path in crontab file to prevent issues




                  You can refer this URL reference
                  Ubuntu Cron HowTo






                  share|improve this answer












                  Docker I prefer to create Dockerfile and run it with --restart=always tag



                  If you want to run your shell script on boot
                  Then use unix's crontab It's very easy to use & you can configure in minutes





                  1. Edit crontab run the following replacing the "USER" with your desired runtime user for the node process. If you choose a different user other than yourself, you will have to run this with sudo.



                    $ crontab -u USER -e




                  2. Once in the editor add the following line:



                    @reboot sh /home/mc/server/craftbukkit.sh




                  3. Save & confirm file is saved by check command of #1 again



                    Note: In my opinion, you should use the full path in crontab file to prevent issues




                  You can refer this URL reference
                  Ubuntu Cron HowTo







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 21 at 12:00









                  Chandani Patel

                  537




                  537






























                      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.





                      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%2f44903%2fhow-to-start-a-script-file-on-boot%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

                      サソリ

                      広島県道265号伴広島線

                      Accessing regular linux commands in Huawei's Dopra Linux