How Do I Wait in Linux?
Contents

When wait command is executed with $process_id then the next command will wait for completing the task of the first echo command. The second wait command is used with ‘$! ‘ and this indicate the process id of the last running process.

What does wait () do in Linux?

wait is an inbuilt command in the Linux shell. It waits for the process to change its state i.e. it waits for any running process to complete and returns the exit status.

How do you wait for a process to finish in Linux?

You can use the bash builtin wait : $ sleep 10 & [2] 28751 $ wait 28751 [2]- Done sleep 10 $ help wait wait: wait [-n] [id …] Wait for job completion and return exit status. Waits for each process identified by an ID, which may be a process ID or a job specification, and reports its termination status.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest