wait - is a built-in command of Linux that waits for completing any running process.
syntax $ wait [options] ID
To wait for a background process with PID 7872 $ wait 7872
$ rsync -a /home/Documents /tmp/Documents & [1] 78724
$ wait %1
To make waits for any multiple background job to complete and return the job exit status $ wait -n <pid_1> <pid_2> <pid_3>
wait command in shell scripts $ vim wait.sh #!/bin/bash sleep 20 & process_id=$! echo "PID: $process_id" wait $process_id echo "Exit status: $?" :x
$ sh wait.sh
regards, T.Dhanasekar
On Sun 2023-05-21 06:00:00 +0530, Dhanasekar wrote:
wait - is a built-in command of Linux that waits for completing any running process.
It is a shell (e.g. bash) built-in, not linux built-in
$ type wait wait is a shell builtin
Best, Yuchen