rc.local is not running on raspberry pi's startup

13,627

Solution 1

You have to refer to your script using an absolute path.

/home/pi/server-starter &

Notice the absence of the . in comparison to your solution.

Also, you may have to add a reference to the shell right at the beginning of your rc.local.

#!/bin/sh -e
/home/pi/server-starter &
exit 0

Solution 2

to run a script shell "in a script shell" use this :

sh -c /absolute/path/to/script;

to run this script in background use this :

sh -c /absolute/path/to/script &;

Don't forget exit 0 at the end of the file

Share:
13,627
Lucas Barbosa
Author by

Lucas Barbosa

Updated on June 05, 2022

Comments

  • Lucas Barbosa
    Lucas Barbosa about 2 years

    I'm trying to run a simple C code when the pi boots, so I followed the steps on the documentation (https://www.raspberrypi.org/documentation/linux/usage/rc-local.md), but when I start it, it shows this error:

    Failed to start etc/rc.local compatibility.
    See 'systemctl status rc-local.service' for details.
    

    I do as it says and I receive this:

    rc-local.service - /etc/rc.local Compatibility
    Loaded: loaded (/lib/systemd/system/rc-local.service; static)
    Drop-In: /etc/systemd/system/rc-local.service.d
             ttyoutput.conf
    Active: failed (Result: exit-code) since Tue 2015-12-08 10:44:23 UTC; 2min 18s ago
    Process: 451 ExecStart=/etc/rc.local start (code=exit, status=203/EXEC)
    

    My rc.local file looks like this:

    ./home/pi/server-starter &
    
    exit 0
    

    Can anyone show me what I'm doing wrong?