Is /etc/rc.local called twice on boot?

Bo Berglund bo.berglund at gmail.com
Tue Oct 26 21:52:10 UTC 2021


On Tue, 26 Oct 2021 19:30:00 +0200, Oliver Grawert <ogra at ubuntu.com> wrote:

>hi,
>Am Dienstag, dem 26.10.2021 um 19:15 +0200 schrieb Bo Berglund:
>
>> And what does "Starting /etc/rc.local Compatibility..." actually
>> mean? What Compatibility?
>
>rc.local is an anachronism from sysv-init ... systemd does normally not
>use it ... there is a generator that translates that old stuff into
>usable systemd units (i assume that is what prints that message) ... 
>
>perhaps you should consider ripping the code out of rc.local and simply
>use a systemd unit directly to call the script, that way less black
>magic would be involved altogether ...

The whole idea using scripting was created back in 2013 in the RaspberryPi
infancy and I was looking for a way to get to know the RPi IP address when the
computer starts up (similar to using the autoexec.bat on MsDos in the PC
beginnings).
All of my RPi boxes are headless and require access via the network, so the
address is needed.

What I was adviced is to put the calls into rc.local and it has worked since
then. I have no idea myself how Linux comes to life on startup so I have no
alternative solution.

But now I have found I use cron instead.

There is one caveat though, the PATH is not set inside a cron environment so my
script fails since it uses utilities located in directories not on the cron
path.

But it could be remedied by adding a simple line before all of the lines setting
up the jobs. I checked my own PATH and copied it into the crontab.

So I have added two lines:

PATH=/home/bosse/bin:/home/bosse/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

@reboot ipreport.sh 60 > /dev/null 2>&1

And I have commented out the call in /etc/rc.local

With this in place it actually does the job of sending *exactly one* message on
reboot.


-- 
Bo Berglund
Developer in Sweden





More information about the ubuntu-users mailing list