I am trying to run this program at boot up. Its file path is /home/pi/shutdown.py. The reason why I ask is because I have tried to use multiple different boot up sequences listed in the following website Execute script on start-up
Is there any way to get this script to run in the background at boot (I have to run other scripts as well)?
import RPi.GPIO as GPIO import time import os GPIO.setmode(GPIO.BOARD) #setting the giop pins up note how this is pin 23 on the pi GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) #the pin is pulled down and will wait for a raiceing edge def printFunction(channel): GPIO.cleanup() print("power button was pushed will shut down now") time.sleep(1) os.system("sudo shutdown -h now") GPIO.add_event_detect(23, GPIO.RISING, callback=printFunction, bouncetime=300)