Wait
Encyclopedia : W : WA : WAI : Wait
- For the British town pipers, see Wait (musician). For the Beatles song, see Wait (song).
- The correct title of this } is }}}. The initial letter is capitalized due to [Naming conventions #Lower case first lettertechnical restrictions].
Usage
wait [n]Where n is the pid or job number 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 code 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.
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 (somewhat contrived) 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.
#!/bin/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
External links
| Unix command line programs ( ) | |||
| File and file system management: | cat | chdir/cd | chmod | chown | chgrp | cp | du | df | fdupes | file | fsck | ln | ls | lsof | mkdir | more | mount | mv | pwd | rcp | rm | rmdir | split | touch | tree | ||
| Process management: | anacron | at | chroot | cron/crontab | kill | nice | ps | sleep | time | timex | top | renice | wait | ||
| User Management/Environment: | env | finger | id | locale | mesg | passwd | su | sudo | uname | uptime | w | who | write | ||
| Text processing: | awk | cut | diff | ex | head | iconv | join | less | more | nkf | paste | sed | sort | tail | tr | uniq | wc | xargs | ||
| Shell programming: | echo | expr | unset | Printing: | lp |
| Communications: inetd | netstat | ping | rlogin | traceroute | Searching: egrep | fgrep | find | grep | strings | Miscellaneous: banner | bc | cal | man | uname | wall | yes | |
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
