Getting program to run from boot (Raspberry Pi)

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.
Post Reply
RGV250
Posts: 359
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 35 times
Been thanked: 39 times

Getting program to run from boot (Raspberry Pi)

Post by RGV250 »

Hi,
I usually use the information at the end of this guide https://www.flowcode.co.uk/wiki/index.p ... rted_Guide once I am happy with the code.
Unfortunately it seems with the latest OS that rc.local no longer exists. Instead of using sudo nano /etc/rc.local using sudo nano /home/pi/.bashrc will do the same thing.

Regards,
Bob

LeighM
Valued Contributor
Posts: 522
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 89 times
Been thanked: 277 times

Re: Getting program to run from boot (Raspberry Pi)

Post by LeighM »

Thanks for the heads up on that, just to add a bit of caution...

/home/pi/.bashrc will only run when you log in,
which happens automatically when you boot up and go directly to the desktop
and also every time when a new terminal is opened, or when a new SSH connection is made.

A search found this, but I've not had chance to test it...
rc.local is still executed, if present, but you will have to create it yourself if you want to use it.
Make sure it's owned by root and has protection 755 or it will not get executed.

RGV250
Posts: 359
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 35 times
Been thanked: 39 times

Re: Getting program to run from boot (Raspberry Pi)

Post by RGV250 »

Hi,
I did see that bit about creating the file but wondered if I needed to add all the other stuff it had in it? Also I do not know much about the permissions or protection.
Going forward, I wonder if it would be better to copy rc.local from an old device and paste into the one with the new OS?

Thanks for the warning as I did not know that, anyway, for now it runs my Christmas tree lights which is the main thing.

Regards,
Bob

LeighM
Valued Contributor
Posts: 522
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 89 times
Been thanked: 277 times

Re: Getting program to run from boot (Raspberry Pi)

Post by LeighM »

These changes relate to the recent adoption of systemd. As a user of Unix/Linux for several decades it's all unwelcome changes for me :?

Post Reply