I was following this tutorial to add a power button to my raspberry pi. I created a script that will start and stop a python script called shutdown.sh. When reboot the system and push the button, it doesn't shut down. I opened ssh and looked for all the services running with the command sudo service --status-all. This is my partial list.
Noticed that shutdown.shis not running. Based on the tutorial, the command I used to register the script is sudo update-rc.d shutdown.sh defaults. I tried manually running the service by adding this command: sudo /etc/init.d/listen-for-shutdown.sh start
I get an error: sudo: unable to execute /etc/init.d/shutdown.sh: No such file or directory. However, the file is there and the filename is correct. I changed the permissions so that it has execution permissions. Just FYI, the python script is where it is supposed to be also. Also, I tested the python script also manually, so I know that works.
- How can I get
shutdown.shservice to run on boot? - Why can't run the script manually when the file is there?
shutdown.sh script:
#! /bin/sh ### BEGIN INIT INFO # Provides: shutdown.py # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO # If you want a command to always run, put it here # Carry out specific functions when asked to by the system case "$1" in start) echo "Starting shutdown.py" /usr/local/bin/shutdown.py & ;; stop) echo "Stopping shutdown.py" pkill -f /usr/local/bin/shutdown.py ;; *) echo "Usage: /etc/init.d/shutdown.sh {start|stop}" exit 1 ;; esac exit 0 