0

I need to run two commands in parallel and get the output from both in the same shell.

Edit:

I am trying to run multiple long-running commands that watch the file system and compile various things for me (CoffeeScript, Jade, sass).

3
  • 3
    What problems are you facing? Commented May 15, 2013 at 18:21
  • 1
    What are you doing to run them in parallel? Commented May 15, 2013 at 18:24
  • possible duplicate:Run parallel multiple commands at once in the same terminal Commented May 15, 2013 at 18:35

2 Answers 2

3
command1 &
command2 &

They're both running in parallel; their output goes to the screen.

Sign up to request clarification or add additional context in comments.

1 Comment

You may want to add a 'wait' to the end of the script
2

You're probably looking at wait command in bash. Consider this script:

#!/bin/bash

FAIL=0
echo "starting"

./script1 &
./script2 &

for job in `jobs -p`
do
   echo $job
   wait $job || let "FAIL+=1"
done

echo $FAIL

if [ "$FAIL" == "0" ];
then
    echo "All jobs completed!"
else
    echo "Jobs FAILED: ($FAIL)"
fi

Courtesy

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.