Bash shell内置wait命令简介
发布时间:2020-12-15 20:04:03 所属栏目:安全 来源:网络整理
导读:转自:http://nanxiao.me/bash-shell-wait/ Bash shell 内置了 wait 命令,官方文档对 wait 解释如下: wait wait [-n] [jobspec or pid …]Wait until the child process specified by each process ID pid or job specification jobspec exits and return
转自:http://nanxiao.me/bash-shell-wait/
wait
wait [-n] [jobspec or pid …]
Wait until the child process specified by each process ID pid or job specification jobspec exits and return the exit status of the last command waited for. If a job spec is given,all processes in the job are waited for. If no arguments are given,all currently active child processes are waited for,and the return status is zero. If the -n option is supplied,wait waits for any job to terminate and returns its exit status. If neither jobspec nor pid specifies an active child process of the shell,the return status is 127.
wait命令可以使当前 root# sleep 10 &
[3] 876
root# wait 876
[3]+ Done sleep 10
root# sleep 20 &
[1] 877
root# wait %1
[1]+ Done sleep 20
wait命令一个很重要用途就是在 command1 &
command2 &
wait
Bash shell还有一个内置变量: root# sleep 20 &
[1] 874
root# sleep 10 &
[2] 875
root# echo $!
875
echo $!输出结果是 参考资料: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |