Bash script not running at startup from rc.local












2















I have written a simple bash script:



#!/bin/bash
echo "hi" > log
exit 0


made it executable and its successfully running.
I edited my rc.local to the following:



#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/katph/test.sh

exit 0


rc.local is executable:



/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug 1 13:19 /etc/rc.local


What's working:



1.I directly put echo "hi" > /home/katph/log in rc.local, it works fine.Meaning rc.local runs at startup.



2.If I manually run rc.local with the script, log file is created correctly.



Any suggestion? I'm running Kubuntu14.04.










share|improve this question























  • If you run bash -x /etc/rc.local, do you see any action?

    – Karl Richter
    Aug 1 '15 at 8:38
















2















I have written a simple bash script:



#!/bin/bash
echo "hi" > log
exit 0


made it executable and its successfully running.
I edited my rc.local to the following:



#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/katph/test.sh

exit 0


rc.local is executable:



/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug 1 13:19 /etc/rc.local


What's working:



1.I directly put echo "hi" > /home/katph/log in rc.local, it works fine.Meaning rc.local runs at startup.



2.If I manually run rc.local with the script, log file is created correctly.



Any suggestion? I'm running Kubuntu14.04.










share|improve this question























  • If you run bash -x /etc/rc.local, do you see any action?

    – Karl Richter
    Aug 1 '15 at 8:38














2












2








2


1






I have written a simple bash script:



#!/bin/bash
echo "hi" > log
exit 0


made it executable and its successfully running.
I edited my rc.local to the following:



#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/katph/test.sh

exit 0


rc.local is executable:



/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug 1 13:19 /etc/rc.local


What's working:



1.I directly put echo "hi" > /home/katph/log in rc.local, it works fine.Meaning rc.local runs at startup.



2.If I manually run rc.local with the script, log file is created correctly.



Any suggestion? I'm running Kubuntu14.04.










share|improve this question














I have written a simple bash script:



#!/bin/bash
echo "hi" > log
exit 0


made it executable and its successfully running.
I edited my rc.local to the following:



#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/katph/test.sh

exit 0


rc.local is executable:



/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug 1 13:19 /etc/rc.local


What's working:



1.I directly put echo "hi" > /home/katph/log in rc.local, it works fine.Meaning rc.local runs at startup.



2.If I manually run rc.local with the script, log file is created correctly.



Any suggestion? I'm running Kubuntu14.04.







bash startup






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 1 '15 at 8:12









Lalit KumarLalit Kumar

13113




13113













  • If you run bash -x /etc/rc.local, do you see any action?

    – Karl Richter
    Aug 1 '15 at 8:38



















  • If you run bash -x /etc/rc.local, do you see any action?

    – Karl Richter
    Aug 1 '15 at 8:38

















If you run bash -x /etc/rc.local, do you see any action?

– Karl Richter
Aug 1 '15 at 8:38





If you run bash -x /etc/rc.local, do you see any action?

– Karl Richter
Aug 1 '15 at 8:38










2 Answers
2






active

oldest

votes


















5














Replace



log


by an absolute path



/home/katph/log




E.G.



#!/bin/bash
echo "hi" > /home/katph/log
exit 0





share|improve this answer

































    0














    To see the log of rc.local itself, it's better to run these commands:



    systemctl restart rc-local.service



    systemctl status rc-local.service



    May be it can be help full for better trouble shooting






    share|improve this answer








    New contributor




    Ataeifard 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: "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%2f655296%2fbash-script-not-running-at-startup-from-rc-local%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









      5














      Replace



      log


      by an absolute path



      /home/katph/log




      E.G.



      #!/bin/bash
      echo "hi" > /home/katph/log
      exit 0





      share|improve this answer






























        5














        Replace



        log


        by an absolute path



        /home/katph/log




        E.G.



        #!/bin/bash
        echo "hi" > /home/katph/log
        exit 0





        share|improve this answer




























          5












          5








          5







          Replace



          log


          by an absolute path



          /home/katph/log




          E.G.



          #!/bin/bash
          echo "hi" > /home/katph/log
          exit 0





          share|improve this answer















          Replace



          log


          by an absolute path



          /home/katph/log




          E.G.



          #!/bin/bash
          echo "hi" > /home/katph/log
          exit 0






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 1 '15 at 9:19









          A.B.

          69.1k12172265




          69.1k12172265










          answered Aug 1 '15 at 8:29









          CyrusCyrus

          3,22621022




          3,22621022

























              0














              To see the log of rc.local itself, it's better to run these commands:



              systemctl restart rc-local.service



              systemctl status rc-local.service



              May be it can be help full for better trouble shooting






              share|improve this answer








              New contributor




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

























                0














                To see the log of rc.local itself, it's better to run these commands:



                systemctl restart rc-local.service



                systemctl status rc-local.service



                May be it can be help full for better trouble shooting






                share|improve this answer








                New contributor




                Ataeifard 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







                  To see the log of rc.local itself, it's better to run these commands:



                  systemctl restart rc-local.service



                  systemctl status rc-local.service



                  May be it can be help full for better trouble shooting






                  share|improve this answer








                  New contributor




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










                  To see the log of rc.local itself, it's better to run these commands:



                  systemctl restart rc-local.service



                  systemctl status rc-local.service



                  May be it can be help full for better trouble shooting







                  share|improve this answer








                  New contributor




                  Ataeifard 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




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









                  answered 13 mins ago









                  AtaeifardAtaeifard

                  11




                  11




                  New contributor




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





                  New contributor





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






                  Ataeifard 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 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%2f655296%2fbash-script-not-running-at-startup-from-rc-local%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

                      GameSpot

                      connect to host localhost port 22: Connection refused

                      Getting a Wifi WPA2 wifi connection