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

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM