Search code examples
pythonshellraspberry-piraspbian

Start shell script on Raspberry Pi startup


I have a python program which posts to my local web server. The script runs on a raspberry pi running the latest version of raspbian 3.18. How can I make the Python script run at startup? Raspbian has a login password which is the first thing I have to remove. If the power ever goes out I want the pi to reboot and start running my script again. Should I be using Raspbian for this? The script is the only thing the pi is used for. I tried adding the script to /etc/init.d but I do not think it will run either way if the pi requires login info upon booting.


Solution

  • Make sure the program is executable

    chmod +x filename.py
    

    open /etc/rc.local in your editor of choice

    sudo nano /etc/rc.local
    

    and add

    python /FULL PATH TO SCRITP/filename.py
    

    before the exit