Skip to main content
deleted 1 character in body
Source Link
Alexander Mills
  • 10.9k
  • 27
  • 120
  • 214

I have this bash script to start some servers:

services=(
    account-service
    reminder-service
    activity-service
    socket-service
    chat-service
    web-app
)


for s in "${services[@]}"; do

 (
   set -e;
   cd "$s"
   git pull
   echonpm "$cmd"start ||| bashexit 1 # always fails
 ) &

 sleep 1;

done

wait;

Sometimes the git pull command will fail. But the failure is deep in the logs and not always obvious. How can I abort the whole script if one of the commands in the subshell exits with 1?

I have this bash script to start some servers:

services=(
    account-service
    reminder-service
    activity-service
    socket-service
    chat-service
    web-app
)


for s in "${services[@]}"; do

 (
   set -e;
   cd "$s"
   git pull
   echo "$cmd" | bash
 ) &

 sleep 1;

done

wait;

Sometimes the git pull command will fail. But the failure is deep in the logs and not always obvious. How can I abort the whole script if one of the commands in the subshell exits with 1?

I have this bash script to start some servers:

services=(
    account-service
    reminder-service
    activity-service
    socket-service
    chat-service
    web-app
)


for s in "${services[@]}"; do

 (
   set -e;
   cd "$s"
   git pull
   npm start || exit 1 # always fails
 ) &

 sleep 1;

done

wait;

Sometimes the git pull command will fail. But the failure is deep in the logs and not always obvious. How can I abort the whole script if one of the commands in the subshell exits with 1?

Tweaked punctuation, capitalization and grammar.
Source Link

Bash listen for exit of background process

I have this bash script to start some servers:

services=(
    account-service
    reminder-service
    activity-service
    socket-service
    chat-service
    web-app
)


for s in "${services[@]}"; do

 (
   set -e;
   cd "$s"
   git pull
   echo "$cmd" | bash
 ) &

 sleep 1;

done

wait;

sometimesSometimes the git pull command will fail. But the failure is deep in the logs and not always obviouslyobvious. How can I abort the whole script if one of the commands in the subshell exits with 1?

Bash listen for exit of background process

I have this bash script to start some servers:

services=(
    account-service
    reminder-service
    activity-service
    socket-service
    chat-service
    web-app
)


for s in "${services[@]}"; do

 (
   set -e;
   cd "$s"
   git pull
   echo "$cmd" | bash
 ) &

 sleep 1;

done

wait;

sometimes the git pull command will fail. But the failure is deep in the logs and not always obviously. How can I abort the whole script if one of the commands in the subshell exits with 1?

Bash listen for exit of background process

I have this bash script to start some servers:

services=(
    account-service
    reminder-service
    activity-service
    socket-service
    chat-service
    web-app
)


for s in "${services[@]}"; do

 (
   set -e;
   cd "$s"
   git pull
   echo "$cmd" | bash
 ) &

 sleep 1;

done

wait;

Sometimes the git pull command will fail. But the failure is deep in the logs and not always obvious. How can I abort the whole script if one of the commands in the subshell exits with 1?

Source Link
Alexander Mills
  • 10.9k
  • 27
  • 120
  • 214

Bash listen for exit of background process

I have this bash script to start some servers:

services=(
    account-service
    reminder-service
    activity-service
    socket-service
    chat-service
    web-app
)


for s in "${services[@]}"; do

 (
   set -e;
   cd "$s"
   git pull
   echo "$cmd" | bash
 ) &

 sleep 1;

done

wait;

sometimes the git pull command will fail. But the failure is deep in the logs and not always obviously. How can I abort the whole script if one of the commands in the subshell exits with 1?