User avatar
Gubba Monster
Posts: 41
Joined: Wed Apr 01, 2020 9:52 pm
Contact: Website

Running a Script after boot finishes

Mon May 25, 2020 4:25 pm

Hello everyone,
My cousin and I wanted to create a pocket console just for fun, and we wanted games to boot up immediately after the boot was finished. I know of a number of options, but I wanted to know which one was the best. I just want to make it clear that I do not want to boot to a desktop as part of the process, and the software I will be using is Raspbian Buster Lite.

Any help would be appreciated
Gubba Monster

deepo
Posts: 574
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: Running a Script after boot finishes

Mon May 25, 2020 4:34 pm


User avatar
Gubba Monster
Posts: 41
Joined: Wed Apr 01, 2020 9:52 pm
Contact: Website

Re: Running a Script after boot finishes

Mon May 25, 2020 7:24 pm

Thank you for the links.
I`ve heard about rc.local, but I was told that it runs during the boot, instead of running after.
With Cron, what command would it be for running after boot, because I saw the

Code: Select all

@reboot
command. Is there a command for running right after boot?
Thanks again,
Gubba Monster

User avatar
Gubba Monster
Posts: 41
Joined: Wed Apr 01, 2020 9:52 pm
Contact: Website

Re: Running a Script after boot finishes

Mon May 25, 2020 8:19 pm

Actually, after double checking those links, the rc.local file will allow a boot if an ampersand is at the end of your code:

Code: Select all

python3 /home/pi/myscript.py &
otherwise it will not boot. I still think cron could be a better option, though because I don't think it interrupts the boot, but correct me if I'm wrong.
Thanks again,
Gubba Monster

deepo
Posts: 574
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: Running a Script after boot finishes

Tue May 26, 2020 5:19 pm

To my knowledge there is no option to have a script to run "after" reboot, but people have used e.g. sleep 30 && myscript.sh to be sure that the pi has booted.

/Mogens

Return to “General discussion”