is Shell scripts execution synchronous?

sh, shell

Solution

While i'm not fully sure what you want to know, here are some common things.

You can run paralell scripts - sending them to the background, like:

script1 &
script2 &
script3 &

all 3 script will run in "parallel".

Now probably what you want to know - serial execution, when the second is depend on first.

It is achieved with `pipe` mechanism. Imagine:

long_running_script_what_produdes_lines | wc -l

both programs are run simultaneously, and the `wc` waits for the output from the `long_running_script_what_produdes_lines` and will count the the all lines.

Here are other `IPC` (InterProcess communication) methods too, (e.g. named pipes, signals).

If you need to know something other, please rephrase the question.

Problem

By default Shell scripts execution is synchronous in behaviour? ``` Script1 Script2 ``` I have a script1 which will take more than 4 mins to complete and the next job is dependant on this.(Similar to producer and consumer problem). Wanted to know whether the script2 waits till script1 complete the execution.

Original source