How to run simple command on startup on FreeBSD?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I need to run a very simple command at startup on my machine using FreeBSD:



cd /home/portal
mv portal.sqlite corrupt_portal.sqlite


This is clearly not a daemon or a service, just a one time command at every boot.



I tried to put a .sh file inside /usr/local/etc/rc.d/ with #!/bin/bash and it doesn't do anything, I also tried to simply write touch testfile
If I run both versions manually they work with no problem.



What am I missing here?










share|improve this question















migrated from serverfault.com Sep 11 at 7:48


This question came from our site for system and network administrators.














  • I'm not sure you're missing anything, freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/… - You can see the order using rcorder: forums.freebsd.org/threads/… .
    – Rob
    Sep 11 at 8:47










  • Related: stackoverflow.com/a/52036993/4694621
    – Mateusz Piotrowski
    Sep 11 at 19:11














up vote
3
down vote

favorite












I need to run a very simple command at startup on my machine using FreeBSD:



cd /home/portal
mv portal.sqlite corrupt_portal.sqlite


This is clearly not a daemon or a service, just a one time command at every boot.



I tried to put a .sh file inside /usr/local/etc/rc.d/ with #!/bin/bash and it doesn't do anything, I also tried to simply write touch testfile
If I run both versions manually they work with no problem.



What am I missing here?










share|improve this question















migrated from serverfault.com Sep 11 at 7:48


This question came from our site for system and network administrators.














  • I'm not sure you're missing anything, freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/… - You can see the order using rcorder: forums.freebsd.org/threads/… .
    – Rob
    Sep 11 at 8:47










  • Related: stackoverflow.com/a/52036993/4694621
    – Mateusz Piotrowski
    Sep 11 at 19:11












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I need to run a very simple command at startup on my machine using FreeBSD:



cd /home/portal
mv portal.sqlite corrupt_portal.sqlite


This is clearly not a daemon or a service, just a one time command at every boot.



I tried to put a .sh file inside /usr/local/etc/rc.d/ with #!/bin/bash and it doesn't do anything, I also tried to simply write touch testfile
If I run both versions manually they work with no problem.



What am I missing here?










share|improve this question















I need to run a very simple command at startup on my machine using FreeBSD:



cd /home/portal
mv portal.sqlite corrupt_portal.sqlite


This is clearly not a daemon or a service, just a one time command at every boot.



I tried to put a .sh file inside /usr/local/etc/rc.d/ with #!/bin/bash and it doesn't do anything, I also tried to simply write touch testfile
If I run both versions manually they work with no problem.



What am I missing here?







freebsd startup






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 16 at 12:17









Jeff Schaller

33.1k849111




33.1k849111










asked Sep 11 at 7:42









Sandro Antonucci

1161




1161




migrated from serverfault.com Sep 11 at 7:48


This question came from our site for system and network administrators.






migrated from serverfault.com Sep 11 at 7:48


This question came from our site for system and network administrators.













  • I'm not sure you're missing anything, freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/… - You can see the order using rcorder: forums.freebsd.org/threads/… .
    – Rob
    Sep 11 at 8:47










  • Related: stackoverflow.com/a/52036993/4694621
    – Mateusz Piotrowski
    Sep 11 at 19:11
















  • I'm not sure you're missing anything, freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/… - You can see the order using rcorder: forums.freebsd.org/threads/… .
    – Rob
    Sep 11 at 8:47










  • Related: stackoverflow.com/a/52036993/4694621
    – Mateusz Piotrowski
    Sep 11 at 19:11















I'm not sure you're missing anything, freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/… - You can see the order using rcorder: forums.freebsd.org/threads/… .
– Rob
Sep 11 at 8:47




I'm not sure you're missing anything, freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/… - You can see the order using rcorder: forums.freebsd.org/threads/… .
– Rob
Sep 11 at 8:47












Related: stackoverflow.com/a/52036993/4694621
– Mateusz Piotrowski
Sep 11 at 19:11




Related: stackoverflow.com/a/52036993/4694621
– Mateusz Piotrowski
Sep 11 at 19:11










2 Answers
2






active

oldest

votes

















up vote
3
down vote













The rc(8) script is responsible for running the automatic boot process, and the example section of the manual gives a simple template for the /etc/rc.d/ directory. Read the rc.subr(8) manual page for further guidance on writing startup scripts.



However, one of the final stages of the automatic boot process is to read a script file called /etc/rc.local (if it exists). This file requires no special formatting or keywords, or the execute bit set.



From the rc(8) manual page:




Typically, the /usr/local/etc/rc.d/ mechanism is used instead of rc.local these days but if you want to use rc.local, it is still supported.







share|improve this answer



























    up vote
    1
    down vote













    The easiest way is to put that command to the crontab.

    Instead of first five fields usually filled as asterisks you can place the special token @reboot



    @reboot root:wheel /path/to/the/command [args ...] 


    This command will be launched each time the system been rebooted.






    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468196%2fhow-to-run-simple-command-on-startup-on-freebsd%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote













      The rc(8) script is responsible for running the automatic boot process, and the example section of the manual gives a simple template for the /etc/rc.d/ directory. Read the rc.subr(8) manual page for further guidance on writing startup scripts.



      However, one of the final stages of the automatic boot process is to read a script file called /etc/rc.local (if it exists). This file requires no special formatting or keywords, or the execute bit set.



      From the rc(8) manual page:




      Typically, the /usr/local/etc/rc.d/ mechanism is used instead of rc.local these days but if you want to use rc.local, it is still supported.







      share|improve this answer
























        up vote
        3
        down vote













        The rc(8) script is responsible for running the automatic boot process, and the example section of the manual gives a simple template for the /etc/rc.d/ directory. Read the rc.subr(8) manual page for further guidance on writing startup scripts.



        However, one of the final stages of the automatic boot process is to read a script file called /etc/rc.local (if it exists). This file requires no special formatting or keywords, or the execute bit set.



        From the rc(8) manual page:




        Typically, the /usr/local/etc/rc.d/ mechanism is used instead of rc.local these days but if you want to use rc.local, it is still supported.







        share|improve this answer






















          up vote
          3
          down vote










          up vote
          3
          down vote









          The rc(8) script is responsible for running the automatic boot process, and the example section of the manual gives a simple template for the /etc/rc.d/ directory. Read the rc.subr(8) manual page for further guidance on writing startup scripts.



          However, one of the final stages of the automatic boot process is to read a script file called /etc/rc.local (if it exists). This file requires no special formatting or keywords, or the execute bit set.



          From the rc(8) manual page:




          Typically, the /usr/local/etc/rc.d/ mechanism is used instead of rc.local these days but if you want to use rc.local, it is still supported.







          share|improve this answer












          The rc(8) script is responsible for running the automatic boot process, and the example section of the manual gives a simple template for the /etc/rc.d/ directory. Read the rc.subr(8) manual page for further guidance on writing startup scripts.



          However, one of the final stages of the automatic boot process is to read a script file called /etc/rc.local (if it exists). This file requires no special formatting or keywords, or the execute bit set.



          From the rc(8) manual page:




          Typically, the /usr/local/etc/rc.d/ mechanism is used instead of rc.local these days but if you want to use rc.local, it is still supported.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 11 at 8:35









          Richard Smith

          801148




          801148






















              up vote
              1
              down vote













              The easiest way is to put that command to the crontab.

              Instead of first five fields usually filled as asterisks you can place the special token @reboot



              @reboot root:wheel /path/to/the/command [args ...] 


              This command will be launched each time the system been rebooted.






              share|improve this answer
























                up vote
                1
                down vote













                The easiest way is to put that command to the crontab.

                Instead of first five fields usually filled as asterisks you can place the special token @reboot



                @reboot root:wheel /path/to/the/command [args ...] 


                This command will be launched each time the system been rebooted.






                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  The easiest way is to put that command to the crontab.

                  Instead of first five fields usually filled as asterisks you can place the special token @reboot



                  @reboot root:wheel /path/to/the/command [args ...] 


                  This command will be launched each time the system been rebooted.






                  share|improve this answer












                  The easiest way is to put that command to the crontab.

                  Instead of first five fields usually filled as asterisks you can place the special token @reboot



                  @reboot root:wheel /path/to/the/command [args ...] 


                  This command will be launched each time the system been rebooted.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 11 at 9:06









                  Kondybas

                  49827




                  49827



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468196%2fhow-to-run-simple-command-on-startup-on-freebsd%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?