Raspberry Pi Autostart: Start the Program automatically

Again and again, it happens that you install Programs, but do not start them automatically when booting. In order to use the Raspberry Pi autostart, all you need to do is to store the information in the /etc/rc.local file in the Linux system.

This is, for example, the case with DNS service noip2. In the following I show how to start a program automatically without much effort, using noip2 as an example.

 

Raspberry Pi Autostart Script

First of all, a Script has to be created in the Directory /etc/init.d/ which starts the Program, so we create a Script (it must not necessarily have a file extension)

sudo nano /etc/init.d/NameOfTheScipt
with the following content:

Instead of noip2, of course, there can be any other Program installed, but be careful that no user interaction is waited (as the confirmation in apt-get), as if it comes to the worst case scenario, it will be waiting for the input at boot time and the Pi will not start.

Next, assign the required rights (Read & Write)

sudo chmod 755 /etc/init.d/NameOfTheScipt
and test the script by starting it
sudo /etc/init.d/NameOfTheScipt start
and stop right away:
sudo /etc/init.d/NameOfTheScipt stop
So that the script is also accessed when booting, we do the following:
sudo update-rc.d NameOfTheScipt defaults
Now the program should run at startup. Should you one day change your mind and want to take the program out of the Autostart, you can do so with:
sudo update-rc.d -f  NameOfTheScipt remove

If you want to know more about the topic, you can do it here.

 

Raspberry Pi Autostart – more options

Another option to start a Script or Program is “Cron”. This makes it possible to start a command (which may be a call to a Program or similar) at a specific time. The time may either be set to e.g. the same time of the day or after the system is booted. Cron offers many customization options, which can be viewed here.

 

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.