1

to run a script at start-up on my Raspberry pi 3 board ( with jessie lite ) :

1- I added one init script under /etc/init.d/ directory. I can start,stop,restart service using script manually.

### BEGIN INIT INFO
# Provides: LCD
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Liquid Crystal Display
# Description: date / time / ip address
### END INIT INFO


#! /bin/sh
# /etc/init.d/lcd


export HOME
case "$1" in
    start)
        echo "Starting LCD"
       /root/Ccodes/charlcd &
    ;;
    stop)
        echo "Stopping LCD"
    killall charlcd
    ;;
    *)
        echo "Usage: /etc/init.d/lcd {start|stop}"
        exit 1
    ;;
esac
exit 0

2-i made the script executable:

"sudo chmod 755 /etc/init.d/lcd"

3-an then Register script to be run at start-up

sudo update-rc.d lcd defaults

the script does not start on boot.

any suggestions?

by the way i can sucsessfully run it at boot using RC.LOCAL https://www.raspberrypi.org/documentation/linux/usage/rc-local.md

1 Answer 1

1

The problem is the init system used on Raspbian wheezy, which is "SysV-style", was replaced in jessie with systemd. This no longer uses inittab or /etc/init.d.

http://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/

https://learn.adafruit.com/running-programs-automatically-on-your-tiny-computer/systemd-writing-and-enabling-a-service

Systemd is widely used beyond the Raspberry Pi and you will also find many general linux based resources around, including those linked at the bottom of the systemd homepage.

2
  • AFAIK systemd runs legacy init.d scripts just fine. Have you tried systemctl enable lcd and systemctl start lcd? Commented Apr 4, 2017 at 11:49
  • yep, but it didnot work! Commented Apr 18, 2017 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.