From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

In computing, wait is a command which pauses until execution of a background process has ended.


 wait [n]

where n is the pid or job ID of a currently executing background process (job). If n is not given, the command waits until all jobs known to the invoking shell have terminated.

wait normally returns the exit status of the last job which terminated. It may also return 127 in the event that n specifies a non-existent job or zero if there were no jobs to wait for.

Because wait needs to be aware of the job table of the current shell execution environment, it is usually implemented as a shell builtin.


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
[2] 1986
$ wait %2 # waits for background job number 2 to terminate, then returns

See also[edit]

External links[edit]


None of the audio/visual content is hosted on this site. All media is embedded from other sites such as GoogleVideo, Wikipedia, YouTube etc. Therefore, this site has no control over the copyright issues of the streaming media.

All issues concerning copyright violations should be aimed at the sites hosting the material. This site does not host any of the streaming media and the owner has not uploaded any of the material to the video hosting servers. Anyone can find the same content on Google Video or YouTube by themselves.

The owner of this site cannot know which documentaries are in public domain, which has been uploaded to e.g. YouTube by the owner and which has been uploaded without permission. The copyright owner must contact the source if he wants his material off the Internet completely.

Powered by YouTube
Wikipedia content is licensed under the GFDL and (CC) license