Linux sleep命令 和 wait命令

man sleep:

SLEEP(1)                         User Commands                        SLEEP(1)

NAME
       sleep - delay for a specified amount of time

SYNOPSIS
       sleep NUMBER[SUFFIX]...
       sleep OPTION

DESCRIPTION
       Pause for NUMBER seconds.  SUFFIX may be `s' for seconds (the default),
       `m' for minutes, `h' for hours or `d' for days.  Unlike most  implemen‐
       tations  that require NUMBER be an integer, here NUMBER may be an arbi‐
       trary floating point number.  Given two or more  arguments,  pause  for
       the amount of time specified by the sum of their values.

       --help display this help and exit

       --version
              output version information and exit

sleep 1    睡眠1秒
sleep 1s    睡眠1秒
sleep 1m   睡眠1分
sleep 1h   睡眠1小时

等待进程完成(wait命令)

格式:    wait  [n]

Shell本身(不通过创建新进程的方法)执行wait,等待进程号为n的后台进程终止,并报告它的终止状态。如默认参数n,则等待Shell上所有当前活动的后台进程终止,并返回代码0。

      wait 命令 保证进程同步 等待一个子进程结束 多个并发就用多个wait
例如:       #!/bin/sh
              echo “1”
              sleep 5&
              echo “3”
              echo “4”
              wait
              echo”5”

深入:

http://www.linuxidc.com/Linux/2011-03/33918.htm

原文地址:https://www.cnblogs.com/youxin/p/3546510.html