Purpose and typical usage of /etc/rc.local












65















The header looks like this:



#!/bin/sh -e
#
# rc.local - executed at the end of each multiuser runlevel
#
# Make sure that the script will "exit 0" on success or any other
# value on error.


What is the reason for this file (it does not contain much), and what commands do you usually put in it? What is a "multiuser runlevel"? (I guess rc is "run commands"?)










share|improve this question




















  • 2





    I don't know if this is the "official" purpose of the file, but I found out that I can use the file for what should happen on startup, and would require super user access, but without having to provide the password. That would typically involve colors, the keyboard, and other such stuff. Check out some examples here.

    – Emanuel Berg
    Aug 7 '13 at 3:10


















65















The header looks like this:



#!/bin/sh -e
#
# rc.local - executed at the end of each multiuser runlevel
#
# Make sure that the script will "exit 0" on success or any other
# value on error.


What is the reason for this file (it does not contain much), and what commands do you usually put in it? What is a "multiuser runlevel"? (I guess rc is "run commands"?)










share|improve this question




















  • 2





    I don't know if this is the "official" purpose of the file, but I found out that I can use the file for what should happen on startup, and would require super user access, but without having to provide the password. That would typically involve colors, the keyboard, and other such stuff. Check out some examples here.

    – Emanuel Berg
    Aug 7 '13 at 3:10
















65












65








65


17






The header looks like this:



#!/bin/sh -e
#
# rc.local - executed at the end of each multiuser runlevel
#
# Make sure that the script will "exit 0" on success or any other
# value on error.


What is the reason for this file (it does not contain much), and what commands do you usually put in it? What is a "multiuser runlevel"? (I guess rc is "run commands"?)










share|improve this question
















The header looks like this:



#!/bin/sh -e
#
# rc.local - executed at the end of each multiuser runlevel
#
# Make sure that the script will "exit 0" on success or any other
# value on error.


What is the reason for this file (it does not contain much), and what commands do you usually put in it? What is a "multiuser runlevel"? (I guess rc is "run commands"?)







debian configuration startup






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 6 '13 at 20:38









Gilles

532k12810661592




532k12810661592










asked Oct 1 '12 at 22:22









Emanuel BergEmanuel Berg

3,67352952




3,67352952








  • 2





    I don't know if this is the "official" purpose of the file, but I found out that I can use the file for what should happen on startup, and would require super user access, but without having to provide the password. That would typically involve colors, the keyboard, and other such stuff. Check out some examples here.

    – Emanuel Berg
    Aug 7 '13 at 3:10
















  • 2





    I don't know if this is the "official" purpose of the file, but I found out that I can use the file for what should happen on startup, and would require super user access, but without having to provide the password. That would typically involve colors, the keyboard, and other such stuff. Check out some examples here.

    – Emanuel Berg
    Aug 7 '13 at 3:10










2




2





I don't know if this is the "official" purpose of the file, but I found out that I can use the file for what should happen on startup, and would require super user access, but without having to provide the password. That would typically involve colors, the keyboard, and other such stuff. Check out some examples here.

– Emanuel Berg
Aug 7 '13 at 3:10







I don't know if this is the "official" purpose of the file, but I found out that I can use the file for what should happen on startup, and would require super user access, but without having to provide the password. That would typically involve colors, the keyboard, and other such stuff. Check out some examples here.

– Emanuel Berg
Aug 7 '13 at 3:10












4 Answers
4






active

oldest

votes


















55














A runlevel is a state of the system, indicating whether it is in the process of booting or rebooting or shutting down, or in single-user mode, or running normally. The traditional init program handles these actions by switching to the corresponding runlevel. Under Linux, the runlevels are by convention:




  • S while booting,

  • 0 while shutting down,

  • 6 while rebooting,

  • 1 in single-user mode and

  • 2 through 5 in normal operation.


Runlevels 2 through 5 are known as multiuser runlevels since they allow multiple users to log in, unlike runlevel 1 which is intended for only the system administrator.



When the runlevel changes, init runs rc scripts (on systems with a traditional init — there are alternatives, such as Upstart and Systemd). These rc scripts typically start and stop system services, and are provided by the distribution.



The script /etc/rc.local is for use by the system administrator. It is traditionally executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel. You might use it to start a custom service, for example a server that's installed in /usr/local. Most installations don't need /etc/rc.local, it's provided for the minority of cases where it's needed.






share|improve this answer





















  • 2





    I found out today that on current FreeBSD, rc.local may get executed pretty early. Definitely not after all normal system services are started. I wanted a beep when sshd access to a headless machine would become available, and rc.local wasn't suitable for this reason. Since the original question is about Debian, this comment is probably irrelevant for the OP.

    – MvG
    Mar 5 '16 at 0:06






  • 1





    @MvG Thanks for the information. rc.local was traditionally run last, but I see that FreeBSD stopped doing that when they switched to a dependency-based system. Mind you, even if rc.local was invoked after /etc/rc.d/sshd, that wouldn't work perfectly: rc.local would be invoked soon after the sshd process was started, it could be invoked before sshd had started to listen to the network (but we'd be talking tenths of a second at most in a typical setup).

    – Gilles
    Mar 5 '16 at 0:42













  • I'm trying to use it to set up network for lxc containers and auto start them. But it stops after iptables-apply /root/iptables. I'm in the process of figuring out what's wrong (waiting for next reboot). But if you've got any suggestions, I'm all ears.

    – x-yuri
    May 18 '16 at 16:28






  • 1





    @x-yuri This requires way more information than what you posted here. I don't even know what “it” is in “it stops”. Ask a new question that explains what you did.

    – Gilles
    May 18 '16 at 16:45



















14














rc denotes "run-control",



The multiuser runlevel would be defined as the level at which networking is available and thus connections to the server could be made using those services in lieu of hard-wired console connections.



Mind you, servers are generally managed by a service processor (under various names) which do support network connections and in turn act as if you indeed had a hard-wired console.



As for the rc.local file, this is a convenience to allow you to specify all of the "local" (site-specific) objects (daemons and/or once-at-boot scripts) you want to start. You may choose to use this paradigm or actually populate '/etc/init.d' with start/stop scripts, appropriately.






share|improve this answer





















  • 1





    Okay, but why is the file there, and when do you typically use it, and how (for example, what commands make sense to put in it)?

    – Emanuel Berg
    Oct 1 '12 at 22:59



















4














The rc.local file on Debian is mostly for compatibility with non-init style systems. You should not use it.



Instead, it is recommended that you copy /etc/init.d/Skeleton to a new init script for whatever you want to happen while changing runlevels, then use inserv to enable it.






share|improve this answer
























  • unix.stackexchange.com/a/480897/5132 /etc/init.d/skeleton is not the way.

    – JdeBP
    Nov 10 '18 at 4:43



















3














I mainly use it for two things:




  1. to log the date and kernel version of every reboot. a simple one-liner that can easily be added to systems without any stuffing around...and far less prone to the boot history being corrupted than running uptimed.


  2. to revive the old /etc/rc.boot/ directory that used to be in debian up until a few years ago. I still have some simple scripts in there that aren't worth the effort of rewriting as an init.d script (e.g. a Q&D script to mail dmesg to root, and another one to use hdaparm to disable idle spindown and blockdev to set read-ahead size), and I'm happy for them to be run after all other boot-time scripts.



e.g.



echo "$(date +%s),$(date),$(uname -a)"  >> /var/log/reboot.log

[ -d /etc/rc.boot ] && run-parts /etc/rc.boot


Also, I wrote /etc/rc.local scripts earlier this year for centos and debian distros to get the ec2-style metadata from openstack (on http://169.254.169.254/) so that VMs would get their IP, hostname, ssh keys, and other instance-specific information. cloud-init has since been ported to these distros, so the scripts are obsolete now.






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%2f49626%2fpurpose-and-typical-usage-of-etc-rc-local%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









    55














    A runlevel is a state of the system, indicating whether it is in the process of booting or rebooting or shutting down, or in single-user mode, or running normally. The traditional init program handles these actions by switching to the corresponding runlevel. Under Linux, the runlevels are by convention:




    • S while booting,

    • 0 while shutting down,

    • 6 while rebooting,

    • 1 in single-user mode and

    • 2 through 5 in normal operation.


    Runlevels 2 through 5 are known as multiuser runlevels since they allow multiple users to log in, unlike runlevel 1 which is intended for only the system administrator.



    When the runlevel changes, init runs rc scripts (on systems with a traditional init — there are alternatives, such as Upstart and Systemd). These rc scripts typically start and stop system services, and are provided by the distribution.



    The script /etc/rc.local is for use by the system administrator. It is traditionally executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel. You might use it to start a custom service, for example a server that's installed in /usr/local. Most installations don't need /etc/rc.local, it's provided for the minority of cases where it's needed.






    share|improve this answer





















    • 2





      I found out today that on current FreeBSD, rc.local may get executed pretty early. Definitely not after all normal system services are started. I wanted a beep when sshd access to a headless machine would become available, and rc.local wasn't suitable for this reason. Since the original question is about Debian, this comment is probably irrelevant for the OP.

      – MvG
      Mar 5 '16 at 0:06






    • 1





      @MvG Thanks for the information. rc.local was traditionally run last, but I see that FreeBSD stopped doing that when they switched to a dependency-based system. Mind you, even if rc.local was invoked after /etc/rc.d/sshd, that wouldn't work perfectly: rc.local would be invoked soon after the sshd process was started, it could be invoked before sshd had started to listen to the network (but we'd be talking tenths of a second at most in a typical setup).

      – Gilles
      Mar 5 '16 at 0:42













    • I'm trying to use it to set up network for lxc containers and auto start them. But it stops after iptables-apply /root/iptables. I'm in the process of figuring out what's wrong (waiting for next reboot). But if you've got any suggestions, I'm all ears.

      – x-yuri
      May 18 '16 at 16:28






    • 1





      @x-yuri This requires way more information than what you posted here. I don't even know what “it” is in “it stops”. Ask a new question that explains what you did.

      – Gilles
      May 18 '16 at 16:45
















    55














    A runlevel is a state of the system, indicating whether it is in the process of booting or rebooting or shutting down, or in single-user mode, or running normally. The traditional init program handles these actions by switching to the corresponding runlevel. Under Linux, the runlevels are by convention:




    • S while booting,

    • 0 while shutting down,

    • 6 while rebooting,

    • 1 in single-user mode and

    • 2 through 5 in normal operation.


    Runlevels 2 through 5 are known as multiuser runlevels since they allow multiple users to log in, unlike runlevel 1 which is intended for only the system administrator.



    When the runlevel changes, init runs rc scripts (on systems with a traditional init — there are alternatives, such as Upstart and Systemd). These rc scripts typically start and stop system services, and are provided by the distribution.



    The script /etc/rc.local is for use by the system administrator. It is traditionally executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel. You might use it to start a custom service, for example a server that's installed in /usr/local. Most installations don't need /etc/rc.local, it's provided for the minority of cases where it's needed.






    share|improve this answer





















    • 2





      I found out today that on current FreeBSD, rc.local may get executed pretty early. Definitely not after all normal system services are started. I wanted a beep when sshd access to a headless machine would become available, and rc.local wasn't suitable for this reason. Since the original question is about Debian, this comment is probably irrelevant for the OP.

      – MvG
      Mar 5 '16 at 0:06






    • 1





      @MvG Thanks for the information. rc.local was traditionally run last, but I see that FreeBSD stopped doing that when they switched to a dependency-based system. Mind you, even if rc.local was invoked after /etc/rc.d/sshd, that wouldn't work perfectly: rc.local would be invoked soon after the sshd process was started, it could be invoked before sshd had started to listen to the network (but we'd be talking tenths of a second at most in a typical setup).

      – Gilles
      Mar 5 '16 at 0:42













    • I'm trying to use it to set up network for lxc containers and auto start them. But it stops after iptables-apply /root/iptables. I'm in the process of figuring out what's wrong (waiting for next reboot). But if you've got any suggestions, I'm all ears.

      – x-yuri
      May 18 '16 at 16:28






    • 1





      @x-yuri This requires way more information than what you posted here. I don't even know what “it” is in “it stops”. Ask a new question that explains what you did.

      – Gilles
      May 18 '16 at 16:45














    55












    55








    55







    A runlevel is a state of the system, indicating whether it is in the process of booting or rebooting or shutting down, or in single-user mode, or running normally. The traditional init program handles these actions by switching to the corresponding runlevel. Under Linux, the runlevels are by convention:




    • S while booting,

    • 0 while shutting down,

    • 6 while rebooting,

    • 1 in single-user mode and

    • 2 through 5 in normal operation.


    Runlevels 2 through 5 are known as multiuser runlevels since they allow multiple users to log in, unlike runlevel 1 which is intended for only the system administrator.



    When the runlevel changes, init runs rc scripts (on systems with a traditional init — there are alternatives, such as Upstart and Systemd). These rc scripts typically start and stop system services, and are provided by the distribution.



    The script /etc/rc.local is for use by the system administrator. It is traditionally executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel. You might use it to start a custom service, for example a server that's installed in /usr/local. Most installations don't need /etc/rc.local, it's provided for the minority of cases where it's needed.






    share|improve this answer















    A runlevel is a state of the system, indicating whether it is in the process of booting or rebooting or shutting down, or in single-user mode, or running normally. The traditional init program handles these actions by switching to the corresponding runlevel. Under Linux, the runlevels are by convention:




    • S while booting,

    • 0 while shutting down,

    • 6 while rebooting,

    • 1 in single-user mode and

    • 2 through 5 in normal operation.


    Runlevels 2 through 5 are known as multiuser runlevels since they allow multiple users to log in, unlike runlevel 1 which is intended for only the system administrator.



    When the runlevel changes, init runs rc scripts (on systems with a traditional init — there are alternatives, such as Upstart and Systemd). These rc scripts typically start and stop system services, and are provided by the distribution.



    The script /etc/rc.local is for use by the system administrator. It is traditionally executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel. You might use it to start a custom service, for example a server that's installed in /usr/local. Most installations don't need /etc/rc.local, it's provided for the minority of cases where it's needed.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 9 at 23:01









    Pablo Bianchi

    501511




    501511










    answered Oct 2 '12 at 0:12









    GillesGilles

    532k12810661592




    532k12810661592








    • 2





      I found out today that on current FreeBSD, rc.local may get executed pretty early. Definitely not after all normal system services are started. I wanted a beep when sshd access to a headless machine would become available, and rc.local wasn't suitable for this reason. Since the original question is about Debian, this comment is probably irrelevant for the OP.

      – MvG
      Mar 5 '16 at 0:06






    • 1





      @MvG Thanks for the information. rc.local was traditionally run last, but I see that FreeBSD stopped doing that when they switched to a dependency-based system. Mind you, even if rc.local was invoked after /etc/rc.d/sshd, that wouldn't work perfectly: rc.local would be invoked soon after the sshd process was started, it could be invoked before sshd had started to listen to the network (but we'd be talking tenths of a second at most in a typical setup).

      – Gilles
      Mar 5 '16 at 0:42













    • I'm trying to use it to set up network for lxc containers and auto start them. But it stops after iptables-apply /root/iptables. I'm in the process of figuring out what's wrong (waiting for next reboot). But if you've got any suggestions, I'm all ears.

      – x-yuri
      May 18 '16 at 16:28






    • 1





      @x-yuri This requires way more information than what you posted here. I don't even know what “it” is in “it stops”. Ask a new question that explains what you did.

      – Gilles
      May 18 '16 at 16:45














    • 2





      I found out today that on current FreeBSD, rc.local may get executed pretty early. Definitely not after all normal system services are started. I wanted a beep when sshd access to a headless machine would become available, and rc.local wasn't suitable for this reason. Since the original question is about Debian, this comment is probably irrelevant for the OP.

      – MvG
      Mar 5 '16 at 0:06






    • 1





      @MvG Thanks for the information. rc.local was traditionally run last, but I see that FreeBSD stopped doing that when they switched to a dependency-based system. Mind you, even if rc.local was invoked after /etc/rc.d/sshd, that wouldn't work perfectly: rc.local would be invoked soon after the sshd process was started, it could be invoked before sshd had started to listen to the network (but we'd be talking tenths of a second at most in a typical setup).

      – Gilles
      Mar 5 '16 at 0:42













    • I'm trying to use it to set up network for lxc containers and auto start them. But it stops after iptables-apply /root/iptables. I'm in the process of figuring out what's wrong (waiting for next reboot). But if you've got any suggestions, I'm all ears.

      – x-yuri
      May 18 '16 at 16:28






    • 1





      @x-yuri This requires way more information than what you posted here. I don't even know what “it” is in “it stops”. Ask a new question that explains what you did.

      – Gilles
      May 18 '16 at 16:45








    2




    2





    I found out today that on current FreeBSD, rc.local may get executed pretty early. Definitely not after all normal system services are started. I wanted a beep when sshd access to a headless machine would become available, and rc.local wasn't suitable for this reason. Since the original question is about Debian, this comment is probably irrelevant for the OP.

    – MvG
    Mar 5 '16 at 0:06





    I found out today that on current FreeBSD, rc.local may get executed pretty early. Definitely not after all normal system services are started. I wanted a beep when sshd access to a headless machine would become available, and rc.local wasn't suitable for this reason. Since the original question is about Debian, this comment is probably irrelevant for the OP.

    – MvG
    Mar 5 '16 at 0:06




    1




    1





    @MvG Thanks for the information. rc.local was traditionally run last, but I see that FreeBSD stopped doing that when they switched to a dependency-based system. Mind you, even if rc.local was invoked after /etc/rc.d/sshd, that wouldn't work perfectly: rc.local would be invoked soon after the sshd process was started, it could be invoked before sshd had started to listen to the network (but we'd be talking tenths of a second at most in a typical setup).

    – Gilles
    Mar 5 '16 at 0:42







    @MvG Thanks for the information. rc.local was traditionally run last, but I see that FreeBSD stopped doing that when they switched to a dependency-based system. Mind you, even if rc.local was invoked after /etc/rc.d/sshd, that wouldn't work perfectly: rc.local would be invoked soon after the sshd process was started, it could be invoked before sshd had started to listen to the network (but we'd be talking tenths of a second at most in a typical setup).

    – Gilles
    Mar 5 '16 at 0:42















    I'm trying to use it to set up network for lxc containers and auto start them. But it stops after iptables-apply /root/iptables. I'm in the process of figuring out what's wrong (waiting for next reboot). But if you've got any suggestions, I'm all ears.

    – x-yuri
    May 18 '16 at 16:28





    I'm trying to use it to set up network for lxc containers and auto start them. But it stops after iptables-apply /root/iptables. I'm in the process of figuring out what's wrong (waiting for next reboot). But if you've got any suggestions, I'm all ears.

    – x-yuri
    May 18 '16 at 16:28




    1




    1





    @x-yuri This requires way more information than what you posted here. I don't even know what “it” is in “it stops”. Ask a new question that explains what you did.

    – Gilles
    May 18 '16 at 16:45





    @x-yuri This requires way more information than what you posted here. I don't even know what “it” is in “it stops”. Ask a new question that explains what you did.

    – Gilles
    May 18 '16 at 16:45













    14














    rc denotes "run-control",



    The multiuser runlevel would be defined as the level at which networking is available and thus connections to the server could be made using those services in lieu of hard-wired console connections.



    Mind you, servers are generally managed by a service processor (under various names) which do support network connections and in turn act as if you indeed had a hard-wired console.



    As for the rc.local file, this is a convenience to allow you to specify all of the "local" (site-specific) objects (daemons and/or once-at-boot scripts) you want to start. You may choose to use this paradigm or actually populate '/etc/init.d' with start/stop scripts, appropriately.






    share|improve this answer





















    • 1





      Okay, but why is the file there, and when do you typically use it, and how (for example, what commands make sense to put in it)?

      – Emanuel Berg
      Oct 1 '12 at 22:59
















    14














    rc denotes "run-control",



    The multiuser runlevel would be defined as the level at which networking is available and thus connections to the server could be made using those services in lieu of hard-wired console connections.



    Mind you, servers are generally managed by a service processor (under various names) which do support network connections and in turn act as if you indeed had a hard-wired console.



    As for the rc.local file, this is a convenience to allow you to specify all of the "local" (site-specific) objects (daemons and/or once-at-boot scripts) you want to start. You may choose to use this paradigm or actually populate '/etc/init.d' with start/stop scripts, appropriately.






    share|improve this answer





















    • 1





      Okay, but why is the file there, and when do you typically use it, and how (for example, what commands make sense to put in it)?

      – Emanuel Berg
      Oct 1 '12 at 22:59














    14












    14








    14







    rc denotes "run-control",



    The multiuser runlevel would be defined as the level at which networking is available and thus connections to the server could be made using those services in lieu of hard-wired console connections.



    Mind you, servers are generally managed by a service processor (under various names) which do support network connections and in turn act as if you indeed had a hard-wired console.



    As for the rc.local file, this is a convenience to allow you to specify all of the "local" (site-specific) objects (daemons and/or once-at-boot scripts) you want to start. You may choose to use this paradigm or actually populate '/etc/init.d' with start/stop scripts, appropriately.






    share|improve this answer















    rc denotes "run-control",



    The multiuser runlevel would be defined as the level at which networking is available and thus connections to the server could be made using those services in lieu of hard-wired console connections.



    Mind you, servers are generally managed by a service processor (under various names) which do support network connections and in turn act as if you indeed had a hard-wired console.



    As for the rc.local file, this is a convenience to allow you to specify all of the "local" (site-specific) objects (daemons and/or once-at-boot scripts) you want to start. You may choose to use this paradigm or actually populate '/etc/init.d' with start/stop scripts, appropriately.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 1 '12 at 23:08

























    answered Oct 1 '12 at 22:51









    JRFergusonJRFerguson

    9,79232430




    9,79232430








    • 1





      Okay, but why is the file there, and when do you typically use it, and how (for example, what commands make sense to put in it)?

      – Emanuel Berg
      Oct 1 '12 at 22:59














    • 1





      Okay, but why is the file there, and when do you typically use it, and how (for example, what commands make sense to put in it)?

      – Emanuel Berg
      Oct 1 '12 at 22:59








    1




    1





    Okay, but why is the file there, and when do you typically use it, and how (for example, what commands make sense to put in it)?

    – Emanuel Berg
    Oct 1 '12 at 22:59





    Okay, but why is the file there, and when do you typically use it, and how (for example, what commands make sense to put in it)?

    – Emanuel Berg
    Oct 1 '12 at 22:59











    4














    The rc.local file on Debian is mostly for compatibility with non-init style systems. You should not use it.



    Instead, it is recommended that you copy /etc/init.d/Skeleton to a new init script for whatever you want to happen while changing runlevels, then use inserv to enable it.






    share|improve this answer
























    • unix.stackexchange.com/a/480897/5132 /etc/init.d/skeleton is not the way.

      – JdeBP
      Nov 10 '18 at 4:43
















    4














    The rc.local file on Debian is mostly for compatibility with non-init style systems. You should not use it.



    Instead, it is recommended that you copy /etc/init.d/Skeleton to a new init script for whatever you want to happen while changing runlevels, then use inserv to enable it.






    share|improve this answer
























    • unix.stackexchange.com/a/480897/5132 /etc/init.d/skeleton is not the way.

      – JdeBP
      Nov 10 '18 at 4:43














    4












    4








    4







    The rc.local file on Debian is mostly for compatibility with non-init style systems. You should not use it.



    Instead, it is recommended that you copy /etc/init.d/Skeleton to a new init script for whatever you want to happen while changing runlevels, then use inserv to enable it.






    share|improve this answer













    The rc.local file on Debian is mostly for compatibility with non-init style systems. You should not use it.



    Instead, it is recommended that you copy /etc/init.d/Skeleton to a new init script for whatever you want to happen while changing runlevels, then use inserv to enable it.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 2 '12 at 0:16









    bahamatbahamat

    24.3k14890




    24.3k14890













    • unix.stackexchange.com/a/480897/5132 /etc/init.d/skeleton is not the way.

      – JdeBP
      Nov 10 '18 at 4:43



















    • unix.stackexchange.com/a/480897/5132 /etc/init.d/skeleton is not the way.

      – JdeBP
      Nov 10 '18 at 4:43

















    unix.stackexchange.com/a/480897/5132 /etc/init.d/skeleton is not the way.

    – JdeBP
    Nov 10 '18 at 4:43





    unix.stackexchange.com/a/480897/5132 /etc/init.d/skeleton is not the way.

    – JdeBP
    Nov 10 '18 at 4:43











    3














    I mainly use it for two things:




    1. to log the date and kernel version of every reboot. a simple one-liner that can easily be added to systems without any stuffing around...and far less prone to the boot history being corrupted than running uptimed.


    2. to revive the old /etc/rc.boot/ directory that used to be in debian up until a few years ago. I still have some simple scripts in there that aren't worth the effort of rewriting as an init.d script (e.g. a Q&D script to mail dmesg to root, and another one to use hdaparm to disable idle spindown and blockdev to set read-ahead size), and I'm happy for them to be run after all other boot-time scripts.



    e.g.



    echo "$(date +%s),$(date),$(uname -a)"  >> /var/log/reboot.log

    [ -d /etc/rc.boot ] && run-parts /etc/rc.boot


    Also, I wrote /etc/rc.local scripts earlier this year for centos and debian distros to get the ec2-style metadata from openstack (on http://169.254.169.254/) so that VMs would get their IP, hostname, ssh keys, and other instance-specific information. cloud-init has since been ported to these distros, so the scripts are obsolete now.






    share|improve this answer




























      3














      I mainly use it for two things:




      1. to log the date and kernel version of every reboot. a simple one-liner that can easily be added to systems without any stuffing around...and far less prone to the boot history being corrupted than running uptimed.


      2. to revive the old /etc/rc.boot/ directory that used to be in debian up until a few years ago. I still have some simple scripts in there that aren't worth the effort of rewriting as an init.d script (e.g. a Q&D script to mail dmesg to root, and another one to use hdaparm to disable idle spindown and blockdev to set read-ahead size), and I'm happy for them to be run after all other boot-time scripts.



      e.g.



      echo "$(date +%s),$(date),$(uname -a)"  >> /var/log/reboot.log

      [ -d /etc/rc.boot ] && run-parts /etc/rc.boot


      Also, I wrote /etc/rc.local scripts earlier this year for centos and debian distros to get the ec2-style metadata from openstack (on http://169.254.169.254/) so that VMs would get their IP, hostname, ssh keys, and other instance-specific information. cloud-init has since been ported to these distros, so the scripts are obsolete now.






      share|improve this answer


























        3












        3








        3







        I mainly use it for two things:




        1. to log the date and kernel version of every reboot. a simple one-liner that can easily be added to systems without any stuffing around...and far less prone to the boot history being corrupted than running uptimed.


        2. to revive the old /etc/rc.boot/ directory that used to be in debian up until a few years ago. I still have some simple scripts in there that aren't worth the effort of rewriting as an init.d script (e.g. a Q&D script to mail dmesg to root, and another one to use hdaparm to disable idle spindown and blockdev to set read-ahead size), and I'm happy for them to be run after all other boot-time scripts.



        e.g.



        echo "$(date +%s),$(date),$(uname -a)"  >> /var/log/reboot.log

        [ -d /etc/rc.boot ] && run-parts /etc/rc.boot


        Also, I wrote /etc/rc.local scripts earlier this year for centos and debian distros to get the ec2-style metadata from openstack (on http://169.254.169.254/) so that VMs would get their IP, hostname, ssh keys, and other instance-specific information. cloud-init has since been ported to these distros, so the scripts are obsolete now.






        share|improve this answer













        I mainly use it for two things:




        1. to log the date and kernel version of every reboot. a simple one-liner that can easily be added to systems without any stuffing around...and far less prone to the boot history being corrupted than running uptimed.


        2. to revive the old /etc/rc.boot/ directory that used to be in debian up until a few years ago. I still have some simple scripts in there that aren't worth the effort of rewriting as an init.d script (e.g. a Q&D script to mail dmesg to root, and another one to use hdaparm to disable idle spindown and blockdev to set read-ahead size), and I'm happy for them to be run after all other boot-time scripts.



        e.g.



        echo "$(date +%s),$(date),$(uname -a)"  >> /var/log/reboot.log

        [ -d /etc/rc.boot ] && run-parts /etc/rc.boot


        Also, I wrote /etc/rc.local scripts earlier this year for centos and debian distros to get the ec2-style metadata from openstack (on http://169.254.169.254/) so that VMs would get their IP, hostname, ssh keys, and other instance-specific information. cloud-init has since been ported to these distros, so the scripts are obsolete now.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 2 '12 at 11:22









        cascas

        38.7k453101




        38.7k453101






























            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%2f49626%2fpurpose-and-typical-usage-of-etc-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

            Morgemoulin

            Scott Moir

            Souastre