linux-command/command/wait.md

48 lines
885 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

wait
===
等待进程执行完后返回
## 补充说明
**wait命令** 用来等待指令的指令直到其执行完毕后返回终端。该指令常用于shell脚本编程中待指定的指令执行完成后才会继续执行后面的任务。该指令等待作业时在作业标识号前必须添加百分号"%"。
### 语法
```shell
wait(参数)
```
### 参数
进程或作业标示:指定进程号或者作业号。
### 实例
使用命令wait等待作业号为1的作业完成后再返回输入如下命令
运行一个sleep进程
```shell
sleep 10s &
[1] 27156
```
指定作业号
```shell
wait %1 #等待作业号为1的作业完成
[1]+ Done sleep 10s
```
指定进程号
```shell
wait 27156
[1]+ Done sleep 10s
```
输出当前存在作业号的指令,如下所示:
[jobs](./jobs.md)