How To Wait Specified Process Termination with wait In Linux and Difference with sleep?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/wait-specified-process-termination-wait-linux-difference-sleep/
PINTEREST
PINTEREST
INSTAGRAM

Linux provides simple and useful tools and commands. wait is one of them. We can use wait command to wait for specified process id and than continue execution of the bash script or interactive shell.

Wait For Specified Process ID

While scripting in bash we may need to wait for some process to continue. So this will pause our script execution. After specified process is completed current script execution will continue. In this example we will wait the process id 2127 .

Wait For Specified Process Name

Working with process ids is not an elegant way. Using process names are better an more readable. But the problem is that same named process can interfere. In this example we assume we have single process with the same name in the system. We will look for process named ssh. We will use pgrep command

Difference with sleep Command

Some new users may confuse sleep with waitcommand. sleep is used to wait specified time period. After this period is completed the execution of the script will continue without related with other process. More detailed about sleep command can be found in the following tutorial.

Bash Sleep In Linux

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/wait-specified-process-termination-wait-linux-difference-sleep/
PINTEREST
PINTEREST
INSTAGRAM

LEARN MORE  Killing Linux Processes With killall Command

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)