Raspberry Pi rc.local startup does not execute problem

Today, I configured the command in /etc/rc.local of pi3, and found that the startup was not executed.

In rc.local I added echo "running rc.local" > /tmp/pre_test.txt before the command that day

Then restart, there is no output from the tmp directory.

Using chmod +x /etc/rc.local command didn't work either

In fact, I have X permissions

It's head-scratching.


Finally check the service status sudo systemctl status rc-local and found the problem:

According to the wrong prompt, running sudo systemctl daemon-reload still has no effect.

Finally, we can only change the method and create the init-app file under /etc/init.d/

#!/bin/sh
#/etc/init.d/init-app

### BEGIN INIT INFO
# Provides:          get-ip-address
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: init-app
# Description: This service is used to start init shell
### END INIT INFO

case "$1" in
    start)
        echo "Starting init.sh"
        sh /var/app/init.sh
         ;;
    stop)
        echo "Stop"
        ;;

    *)
        echo "Usage: service init-app start|stop"
        exit 1
        ;;
esac
exit 0

keep

Add permission

sudo chmod 777 /etc/init.d/init-app

add to boot

sudo update-rc.d init-app defaults


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325756117&siteId=291194637