I have a simple python file(no GUI) that I'd like it to run in the background at start-up of raspberry pi 3b. I checked out this post Execute script on start-up But it didn't specify what to do with python file though. Python script:
import time
import pygame
pygame.init()
pygame.mixer.init()
while True:
sounda=pygame.mixer.Sound("test.wav")
sounda.play()
time.sleep(5)
The complete file is at: https://github.com/adafruit/Adafruit_Python_MPR121/blob/master/examples/playtest.py However I'm unable to make it work, so just used a simpler version instead. Appreciate the help.
.bashrc
- this is extremely poor practice as it will run EVERY time you execute a non-login shell. It is intended to initialise the shell. The other suggestions are obsoleteSysV
code. – Milliways Jul 13 '18 at 03:04/etc/rc.local
(since its been a while since i last used that, i am not sure if it is still the recommended way) – Shreyas Murali Jul 13 '18 at 03:58