wait

Official Description

Awaits process completion.

Syntax

wait [pid]

Options

None

Oddities

The C shell has its own version of this command.

Example

$ sleep 15&                  # Start a job in the background
[1]     1309
$ wait                       # Wait for it to complete
[1] +  Done                    sleep 15&
$
$ sleep 15&                  # Start two jobs in the background
[1]     1310
$ sleep 30&
[2]     1311
$ jobs
[2] +  Running                 sleep 30&
[1] -  Running                 sleep 15&
$
$ wait 1311                  # Wait for a particular one to complete
[1] +  Done                    sleep 15&
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.