Is /etc/rc.local called twice on boot?
Bo Berglund
bo.berglund at gmail.com
Tue Oct 26 17:15:27 UTC 2021
On Tue, 26 Oct 2021 15:54:48 +0100, Colin Law <clanlaw at gmail.com> wrote:
>On Tue, 26 Oct 2021 at 15:19, Bo Berglund <bo.berglund at gmail.com> wrote:
>>
>> On Tue, 26 Oct 2021 10:51:24 +0100, Colin Law <clanlaw at gmail.com> wrote:
>>
>> >>
>> >> This is the *only* command inside rc.local:
>> >>
>> >> /home/bosse/bin/ipreport.sh 60 &
>> >>
>> >
>> >Add a command to log something from there and then you can check
>> >whether it is being called twice or whether something else is going
>> >on.
>>
>> Now done that including a timestamp with seconds, now I have to wait until the
>> next restart to see if it works properly or not.
>
>Another thing to look at is
>grep "rc.local" /var/log/syslog
>and see what it says. If it shows nothing then the log might have
>been rotated so try syslog.1
>
This is what I see:
$ grep "rc.local" /var/log/syslog
Oct 26 17:11:33 ubuntuserv systemd[1]: Starting LSB: Run /etc/rc.local if it
exist...
Oct 26 17:11:33 ubuntuserv systemd[1]: Started LSB: Run /etc/rc.local if it
exist.
Oct 26 17:11:46 ubuntuserv systemd[1]: Starting /etc/rc.local Compatibility...
Oct 26 17:11:46 ubuntuserv systemd[1]: Started /etc/rc.local Compatibility.
Oct 26 17:12:33 ubuntuserv rc.local[957]: Extracted Ethernet IP address:
192.168.119.216 a4:ae:12:7f:4d:c3
Oct 26 17:12:33 ubuntuserv rc.local[957]: Extracted hostname: ubuntuserv
Oct 26 17:12:33 ubuntuserv rc.local[2393]: % Total % Received % Xferd
Average Speed Time Time Time Current
Oct 26 17:12:33 ubuntuserv rc.local[2393]:
Dload Upload Total Spent Left Speed
Oct 26 17:12:33 ubuntuserv rc.local[2393]: #015 0 0 0 0 0 0
0 0 --:--:-- --:--:-- --:--:-- 0#0151
00 115 100 15 100 100 71 478 --:--:-- --:--:-- --:--:-- 550
Oct 26 17:12:33 ubuntuserv rc.local[2393]: <br>Success<br>
Oct 26 17:12:45 ubuntuserv rc.local[1268]: Extracted Ethernet IP address:
192.168.119.216 a4:ae:12:7f:4d:c3
Oct 26 17:12:45 ubuntuserv rc.local[1268]: Extracted hostname: ubuntuserv
Oct 26 17:12:45 ubuntuserv rc.local[2419]: % Total % Received % Xferd
Average Speed Time Time Time Current
Oct 26 17:12:45 ubuntuserv rc.local[2419]:
Dload Upload Total Spent Left Speed
Oct 26 17:12:45 ubuntuserv rc.local[2419]: #015 0 0 0 0 0 0
0 0 --:--:-- --:--:-- --:--:-- 0#0151
00 115 100 15 100 100 50 334 --:--:-- --:--:-- --:--:-- 384
Oct 26 17:12:45 ubuntuserv rc.local[2419]: <br>Success<br>
Notice that the output here matches my log lines and timestamps of received
messages, which also shows that the script is actuallyu being called twice:
2021-10-26 17:12:33 Reporting ipaddr=192.168.119.216
2021-10-26 17:12:45 Reporting ipaddr=192.168.119.216
The strange thing here in the syslog is that there are two "Started" lines at
17:11:33 and 17:11:46
And what does "Starting /etc/rc.local Compatibility..." actually mean?
What Compatibility?
Note:
The stuff between "Extracted Ethernet..." and "Success<br>" is script and curl
screen output since I did not redirect output to /dev/null...
Question:
---------
Is there a way to have grep output lines before and after a specific line hit?
Say I will grep for "Starting /etc/rc.local" and want to see 10 lines before and
after each hit?
Is that possible?
--
Bo Berglund
Developer in Sweden
More information about the ubuntu-users
mailing list