Yeji
Yeji

Reputation: 39

How to make GCP start script to start multiple processes?

So, I'm using Google Cloud Platform and set below startup script

#! /bin/bash
cd /home/user
sudo ./process1
sudo ./process2

I worried about this script because process1 blocks shell and prevent to run sudo ./process2. And it really was. process1 was started successfully but process2 was not started.
I checked that script has no problem with starting process1 and process2. Execute ./process2 via SSH worked but after I close the SSH shell and process2 was stopped too.

How can I start both process in booting time(or even after)?

Upvotes: 0

Views: 590

Answers (2)

Abiramavalli Gopu
Abiramavalli Gopu

Reputation: 93

I tried testing your startup script in my environment,it seems the script works well.

1.You can please try checking process1 and process2 scripts.

2.If you want your process to run in the background even after the SSH session is closed, you can use “&” { your_command & }at the end of your command.

Upvotes: 2

jabbson
jabbson

Reputation: 4913

To run a command in the background, add the ampersand symbol (&) at the end of the command:

your_command &

then the script execution continues and isn't blocked. Or use linux internal means to auto run processes on boot.

Upvotes: 1

Related Questions