Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell script wait till process completes

Tags:

shell

process

I have a process

"verifyEmail"
I run this in script as verifyEmail 0 1000

Now How do I wait until this process is finished executing before moving on to next instruction in shell script ? It takes more than 60 mins for verifyEmail to run

I tried

while ! checkprocess "verifyEmail"; do   ##Checkprocess is a function which returns 0 or 1
sleep 60                                 ## based on process present or not
done 
like image 246
JumpOffBox Avatar asked Feb 16 '26 00:02

JumpOffBox


1 Answers

If you run the process normally, you don't need to do anything. If you run it asynchronously, you just need to wait for it:

verifyEmail 0 1000
echo This will print after verifyEmail is done!

or

verifyEmail 0 1000 &
wait $!
echo This will print after verifyEmail is done!
like image 111
William Pursell Avatar answered Feb 20 '26 07:02

William Pursell