wait builtin
The builtin that pauses a script until its background jobs, or one given job or process, have finished.
In more detail
It returns the exit status of the job it waited for. A script can therefore start several jobs in parallel and still check how each one ended.
Example
sleep 30 & kill -TERM %1; waitRelated terms
- background job — A command started with & at the end of the line, which runs while the shell immediately gives you the prompt back.
- job control — The shell feature for managing the commands it started: listing them with jobs, and moving them between foreground and background with fg and bg.
Taught in
- Processes, Jobs And Signals — Bash Scripting & Command Line Automation