molul
Posts: 11
Joined: Mon Jun 11, 2018 5:42 am

Problem with running script on boot

Thu Apr 25, 2019 6:51 am

I'm making an emulator frontend and I want it to run when I turn the RPi on. The script to launch the application is named "run.sh" and I'm working on Raspbian Stretch Lite.

I currently have "./run.sh &" at the end of "/home/pi/.profile". It works fine, but whenever I have to access the Pi through SSH, the script is executed again and I have to stop both instances.

Is there another way to make this without having the script run again when you access the Pi through SSH?

Thanks in advance.

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Problem with running script on boot

Thu Apr 25, 2019 7:16 am

change it to
if [ $(tty) == /dev/tty1 ]; then
./run.sh
fi
...

edit
see also
https://serverfault.com/questions/26180 ... and-bashrc
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

molul
Posts: 11
Joined: Mon Jun 11, 2018 5:42 am

Re: Problem with running script on boot

Thu Apr 25, 2019 7:47 am

Thank you very much! I promise I've spent months reading dozens of articles about running scripts on boot and never saw this ^_^U

Return to “Raspberry Pi OS”