Wait (command) - Example

Example

This command can be useful where part of a script can execute in parallel to implement a barrier where an upcoming section depends on the successful completion of the preceding sections.

The following example will fetch the src/ directory from a machine named iona using rsync and simultaneously update the libraries on which this program depends, before building the combination.

#!/usr/bin/env bash # Parallel update script which makes use of the wait command # Update local copy rsync iona:src/ . & # Upgrade required libraries, or exit indicating failure if make failed for some reason make -C lib || exit 1 # Wait for rsync to terminate (may have already happened) and finish the job, unless rsync failed wait && make

Wait for specified job control id number:

$ ls -R / > /dev/null 2>&1 & # start any long running background process 1986 $ wait %2 # waits for background job number 2 to terminate, then returns

Read more about this topic:  Wait (command)

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)