Shell 脚本等待进程完成

标签 shell process

我有一个流程

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

现在我如何等到这个过程完成执行后再继续执行 shell 脚本中的下一条指令? verifyEmail 运行需要 60 多分钟

我试过了

while ! checkprocess "verifyEmail"; do   ##Checkprocess is a function which returns 0 or 1
sleep 60                                 ## based on process present or not
done 

最佳答案

如果您正常运行该过程,则无需执行任何操作。如果你异步运行它,你只需要等待:

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

verifyEmail 0 1000 &
wait $!
echo This will print after verifyEmail is done!

关于Shell 脚本等待进程完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15508591/

相关文章:

linux - Unix shell 脚本 : Update timestamp on all sub-directories and sub-files, 包括带空格的脚本

reactjs - Gatsby,浏览器中无法访问环境变量

java - 进程类的 wait 方法不返回

perl - 调试 Perl 脚本

python - 使用 shell 保存包含日期和时间的文件

Linux:如何 'fork' 不在新终端窗口中执行新进程?

linux - conserve/proc/PID/after 进程存在

c++ - 使用 C++ 读取进程本身的标准输出

linux - 设置除/bin/sh 以外的 Linux shell 是否有问题?

regex - awk,字段不匹配但应该匹配