ashwinnat
Posts: 5
Joined: Wed Jul 10, 2019 6:19 am

Startup script from rc.local is not being executed

Wed Aug 14, 2019 3:11 pm

Hi,
My startup script from rc.local is not being executed. When I check the status of the service that runs rc.local, it gives me the following errors.

The rc.local script contents do not have any errors. I validated this by running sudo sh -x /etc/rc.local . This returned no errors

sudo systemctl status rc-local.service gives the following output
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
/etc/systemd/system/rc-local.service.d
└─ttyoutput.conf
Active: failed (Result: exit-code) since Wed 2019-08-14 20:39:00 IST; 1min 8s ago

Aug 14 20:39:00 ganga-cm3 systemd[1255]: rc-local.service: Failed at step STDOUT spawning /etc/rc.local: No such device
Aug 14 20:39:00 ganga-cm3 systemd[1]: Starting /etc/rc.local Compatibility...
Aug 14 20:39:00 ganga-cm3 systemd[1]: rc-local.service: Control process exited, code=exited, status=209/STDOUT
Aug 14 20:39:00 ganga-cm3 systemd[1]: rc-local.service: Failed with result 'exit-code'.
Aug 14 20:39:00 ganga-cm3 systemd[1]: Failed to start /etc/rc.local Compatibility.
Aug 14 20:40:05 ganga-cm3 systemd[1]: /etc/systemd/system/rc-local.service:10: Support for option SysVStartPriority= has been removed and it is ignored
Any help with this will be greatly appreciated.

Thanks,
Ashwin N

gkaiseril
Posts: 639
Joined: Mon Aug 08, 2016 9:27 pm
Location: Chicago, IL

Re: Startup script from rc.local is not being executed

Wed Aug 14, 2019 3:33 pm

Are you booting into the command line?

Can you post your rc.local contents.

Since no user is logged in at the time of the running of the r.local, you need to specify all absolute paths.
f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.

ashwinnat
Posts: 5
Joined: Wed Jul 10, 2019 6:19 am

Re: Startup script from rc.local is not being executed

Fri Aug 16, 2019 7:27 am

The raspbian version is a lite version of Buster. The CM3 is running as a headless (no monitor, keyboard, etc.) setup. We use the Pi over SSH.

I'm not sure what you mean by booting from command line, but I hope that the above points address it.

The rc.local contents are below.

Code: Select all

#!/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.
#usb_modeswitch -J -v 12d1 -p 1f01
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

/root/controller/release/SystemMonitor &
echo "started Sys" >> /root/sys.log
sh /root/startsystem.sh &

exit 0
I don't think there's any issue with the contents of the script, because when the script is called from anywhere using sudo sh -x /etc/rc.local the script runs fine.

Thanks,
Ashwin N

User avatar
thagrol
Posts: 1781
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Startup script from rc.local is not being executed

Fri Aug 16, 2019 6:46 pm

ashwinnat wrote:
Fri Aug 16, 2019 7:27 am
I don't think there's any issue with the contents of the script, because when the script is called from anywhere using sudo sh -x /etc/rc.local the script runs fine.
That's by no means a given, especially if your script relies on networking or other services to be up when it runs. By the time you can log in all that stuff will be up so your script will work.

Prior to systemd it was pretty much a given that rc.local would be the last thing run during boot. With systemd that doesn't seem to be the case.

Try redirecting both stdout and stderr to a file when your script is called from rc.local E.g by adding "> /some/log.file 2>&1" to the end of the line.

You may also find usefult information in the output of

Code: Select all

systemctl status rc-local
Edit:
Or use a systemd service to run your script with apropriatre dependancies rather than running it from rc.local.
This space unintentionally left blank.

bls
Posts: 211
Joined: Mon Oct 22, 2018 11:25 pm

Re: Startup script from rc.local is not being executed

Fri Aug 16, 2019 7:45 pm

ashwinnat wrote:
Wed Aug 14, 2019 3:11 pm
Aug 14 20:39:00 ganga-cm3 systemd[1255]: rc-local.service: Failed at step STDOUT spawning /etc/rc.local: No such device
Why is it getting this error? On Buster, in /lib/systemd/system/rc-local.service, there are these interesting lines:

Code: Select all

# Often contains status messages which users expect to see on the console
# during boot
[Service]
StandardOutput=journal+console
StandardError=journal+console
Is it possible that either your journal or your system console (the HDMI display, I believe) has a problem? I run Buster Lite on a headless Pi, and I don't see this error on my systems.

User avatar
thagrol
Posts: 1781
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Startup script from rc.local is not being executed

Fri Aug 16, 2019 8:29 pm

Those lines aren't present on my buster lite install and I've not manually removed them.

It might be wise for ashwinnat to do some basic trouble shooting: comment out every line they've added to rc.local then uncomment them one at a time with a reboot each time until they find which line breaks things.

If I had to guess I'd be looking to see if the directories and files being used for logging exist and have the correct permissions including whether the partition they're on has been mounted read only or read/write.
This space unintentionally left blank.

Return to “Troubleshooting”