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

Bo Berglund bo.berglund at gmail.com
Tue Oct 26 09:42:41 UTC 2021


On Tue, 26 Oct 2021 09:13:48 +0100, Chris Green <cl at isbd.net> wrote:

>On Tue, Oct 26, 2021 at 12:47:59AM +0200, Bo Berglund wrote:
>> I have a custom call in /etc/rc.local to report the IP address of the system on
>> boot. It is set to run 60 seconds after the rc.local itself gets called.
>> This has worked fine in several installations both on Ubuntu and Raspbian.
>> 
>> But now (maybe since upgrading to 20.04 from 18.04) each time I reboot the call
>> is made twice with about 10 seconds time difference.
>> 
>> So I wonder if /etc/rc.local is called twice during boot nowadays?
>> 
>I rune things from rc.local in 20.04 and haven't seen this happening.
>
>I'd *guess* that something else is reporting the IP address, this is
>done by some things I believe.  You could try removing the call from
>rc.local and see if you still get the IP address reported.
>

This is the *only* command inside rc.local:

/home/bosse/bin/ipreport.sh 60 &

The script itself:
------------------------------------------
#!/bin/bash
#Wait for a minute (at boot time) if no argument supplied, otherwise continue:
if [ -z "$1" ]; then
  DELAY="1"
else
  DELAY="$1"
fi
sleep $DELAY

MyName=$(hostname)
IPAddr=$(ifconfig eth0|grep "inet "|sed 's/ *inet //;s/ .*//')
IPMac=$(ifconfig eth0 | grep -Eo ..\(\:..\){5})

#Send request
curl --data "rpiaddr=$IPAddr" --data "rpiname=$MyName" --data
"rpimacaddr=$IPMac" http://www.myowndomain.com/php/ipreport.php
exit 0
-----------------------------------------

The website script packages the call parameters into an email to myself.
I am getting two emails from this particular device but only one from all of the
others.
THese are Raspberry Pi devices and the script was created years ago in order to
find out the IP address of my RPi devices when they get a DHCP assigned IP. I
use it on all of my Linux machines and it has worked fine also on the Ubuntu up
until I did the release-upgrade a week or so ago from 18.04 to 20.04


-- 
Bo Berglund
Developer in Sweden





More information about the ubuntu-users mailing list