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

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.

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.


    • Totally missed your post, sorry.
      rc.local can execute shell scripts like .bashrc, but is only called once after bootup, not for every created shell.
      init.d scripts is for daemons ect. and scripts in there should have some special formatting, so .bashrc or rc.local are usually best…

Leave a Reply to Jerry Cancel reply

Time limit is exhausted. Please reload CAPTCHA.