Issue
I'm trying to implement a google assistant like chatbot which can be activated by a voice command or which can directly perform an action when a particular voice input is given without any other interactions. I tried running the code in background, but it closes as soon as the terminal is closed. I want to run the code as soon as the pi boots up and such that it takes input all the time without being affected by any other scripts running parallely. Thank you. Any solution will be appreciated.
Solution
This question is better suited for the superuser section of stack exchange, but regardless,
First you would need to make your file executable by running chmod +x /path/to/script
then to run it in the background you could use nohup /path/to/script &
.
To make it run on startup you should look at this article on making it run at startup on a Raspberry Pi:
Now, enter the line:
@reboot sh /home/pi/bbt/launcher.sh >/home/pi/logs/cronlog 2>&1
What this does is rather than executing the launcher script at a >specific time, it will execute it once upon startup.
Where /home/pi/bbt/launcher.sh
is the file you want to run on startup.
Answered By - Ahmouse Answer Checked By - Pedro (WPSolving Volunteer)