sleep (command)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

sleep
Sleep Command
Sleep Command
Developer(s)Microsoft, Microware, Trane Francks
Operating systemUnix, Unix-like, OS-9, FreeDOS, Microsoft Windows
TypeCommand

In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time. The sleep instruction suspends the calling process for at least the specified number of seconds (the default), minutes, hours or days.

The command is also available in the OS-9 shell[1] and part of the FreeDOS Package group Utilities.[2] The FreeDOS version was developed by Trane Francks.[3] In Windows PowerShell, sleep is a predefined command alias for the Start-Sleep cmdlet which serves the same purpose.[4] Microsoft also provides a sleep resource kit tool for Windows which can be used in batch files or the command prompt to pause the execution and wait for some time.[5] Another native version is the timeout command which is part of current versions of Windows.[6]

Usage[edit]

 sleep number

Where number is an integer[7] number to indicate the time period in seconds. Some implementations support floating point numbers.

Options[edit]

None.

Examples[edit]

 sleep 30

Causes the current terminal session to wait 30 seconds.

 sleep 18000

Causes the current terminal session to wait 5 hours

GNU sleep specific Examples[edit]

 sleep 3h ; mplayer foo.mp3

Wait 3 hours then play foo.mp3

Note that sleep 5h30m and sleep 5h 30m are illegal since sleep takes only one value and unit as argument. However, sleep 5.5h (a floating point[8]) is allowed. Consecutive executions of sleep can also be used.

 sleep 5h; sleep 30m

Sleep 5 hours, then sleep another 30 minutes .

The GNU Project's implementation of sleep (part of coreutils) allows the user to pass an arbitrary floating point[8] or multiple arguments, therefore sleep 5h 30m (a space separating hours and minutes is needed) will work on any system which uses GNU sleep, including Linux.

Possible uses for sleep include scheduling tasks and delaying execution to allow a process to start, or waiting until a shared network connection most likely has few users to wget a large file.

See also[edit]

References[edit]

  1. ^ Paul S. Dayan (1992). The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
  2. ^ http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-util.html
  3. ^ http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/sleep.html
  4. ^ https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/start-sleep?view=powershell-6
  5. ^ https://www.microsoft.com/en-us/download/details.aspx?id=17657
  6. ^ https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/cc754891(v%3dws.11)
  7. ^ "sleep(3): sleep for specified number of seconds - Linux man page". linux.die.net. Retrieved 19 April 2018.
  8. ^ a b "GNU Coreutils: sleep invocation". www.gnu.org. Retrieved 19 April 2018.

External links[edit]