Tested on:RPi 3 with Raspbian Jessie, but works for most unix systems
Prerequisites:Raspberry Pi with Raspbian Jessie(see steps 1-5 in the Introduction)
Hardware:LED with resistor and cables
0

Options for autostarting Raspberry Pi programs: init.d, .bashrc and cron

There are different ways for autostarting Raspberry Pi programs. This tutorial will show how to autostart a program on the Raspberry Pi with .bashrc, init.d or a cron job.

Create dummy python script
For visualising the autostart, attach an LED to pin 11 in BOARD numbering.
Create a file test.py with

and fill it with

This script can be autostarted with all of the following options.

.bashrc commands
The .bashrc is a bunch of code that is loaded when a terminal opens (alternatively, commands in bash_profile are executed just once every terminal session).
Open the .bashrc with

then add at the end of the file:

init.d scripts
init.d is a directory for demons: household scripts that are started on boot.
Create a file autostart.sh with

and fill the file with

Save the file, then make the script executable and move it to the appropriate location:

For deactivation, move autostart.sh out of init.d.

cron job
Cron is a job scheduling system that can start programs at given times or events.
Enter

Select the editor nano, then add at the bottom of the file

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.

Comment

Time limit is exhausted. Please reload CAPTCHA.