2

On startup i am trying to make The Pi open terminal run a source command "source env/bin/activate" and then run the command "google-assistant-demo' all while the terminal is still open. This part is crucial as the google assistant development software i am using requires the console to remain open.

This is for a personal assistant product i am using and i have tried creating a executable sh script on startup but that can only run one command and the terminal closes afterwards.

source env/bin/activate

google-assistant-demo

When i try to edit the startup config file the terminal opens for a second and instantly closes.

Jayden Miller
  • 29
  • 1
  • 2

1 Answers1

1

Execute script on start-up

Here you can find a page full of wonderful solutions to run a script at the boot startup of the system. Within a script, you can do almost everything you want (for instance run the command you were speaking about source env/bin/activate). Here another useful link.

How to run a Linux Program on Startup

January 2, 2017 Tim How To, Raspberry Pi


Here are the steps to have a program or script start on boot on a linux machine using Systemctl. I’m currently using this start several services on my raspberry pi. DigitalOcean wrote an article that goes into more detail on Systemctl.

Run this command

sudo nano /etc/systemd/system/YOUR_SERVICE_NAME.service

Paste in the command below. Press ctrl + x then y to save and exit

Description=GIVE_YOUR_SERVICE_A_DESCRIPTION

Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
ExecStart=YOUR_COMMAND_HERE
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

Reload services

sudo systemctl daemon-reload

Enable the service

sudo systemctl enable YOUR_SERVICE_NAME

Start the service

sudo systemctl start YOUR_SERVICE_NAME

Check the status of your service

systemctl status YOUR_SERVICE_NAME

Reboot your device and the program/script should be running. If it crashes it will attempt to restart.

Here the link to the original post. However, it seems that you did not check on Google (or other) before: the web is full of such information and many of them are amazing!

Leos313
  • 5,152
  • 6
  • 40
  • 69