Search code examples
linuxshellterminaldebianboot

Execute a program on boot in linux in terminal


I am working on a project on a raspberry Pi Model 2+ using Raspbian Debian jessie and this is my problem :/

So i have a program (written in C++) that I launch using a shell script (the shell script basically relaunches my program whenever it crashes, this is unsolveable since it will fail once in a while because of the hardware I am using***)

I was looking on google for answers on how to launch a program on boot and saw that i can put everything in RC.local as a script @/etc/RC.local. So now I have this:

sudo /home/pi/Morreels/launcher

in rc.local, this launches the process since i can kill it using killall launcher after being logged in. Sadly i need this program to output to the terminal so that's where i am stuck, i've seen people launching the terminal and then echo'ing the run codes for the program inside the terminal, but isn't this a dirty fix ?

I feel like there should be some kind of option like -lx at the end of my command to make it output into the terminal, no ?

Sadly, about this i don't seem to find anything, and if I SHOULD use the above mentioned dirty fix, i would love some help since I dont seem to get that to work...


Solution

  • Why do you need the output in a terminal? When the rc-scripts are run there simply is no terminal available to redirect the output into.

    Maybe a logfile could help you here? Redirect the output to /var/log/morreels_launcher.log for example and then check this file instead of the terminal?

    PS: The sudo should not be necessary in rc-scripts.