| sleep | |
|---|---|
The sleep command | |
| Developers | AT&T Bell Laboratories,Microsoft,Microware, Trane Francks |
| Initial release | November 1973; 52 years ago (1973-11) |
| Written in | C |
| Operating system | Unix,Unix-like,V,Plan 9,Inferno,OS-9,MSX-DOS,FreeDOS,Windows,KolibriOS,IBM i |
| Platform | Cross-platform |
| Type | Command |
| License | coreutils:GPLv3+ FreeDOS:GPLv2 Plan 9:MIT License |
Incomputing,sleep is acommand inUnix,Unix-like and otheroperating systems thatsuspends program execution for a specified time.
The sleep instruction suspends the callingprocess for at least the specified number of seconds (the default), minutes, hours or days.
sleep forUnix-like systems is part of theX/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and theSingle Unix Specification.[1] It first appeared inVersion 4 Unix.[2]
The version ofsleep bundled inGNUcoreutils was written by Jim Meyering and Paul Eggert.[3] The command is also available in theOS-9 shell,[4] in theKolibriOS Shell,[5] and part of theFreeDOSPackage group Utilities.[6] The FreeDOS version was developed by Trane Francks and is licensed under theGPL.[7]
Asleep command is also part ofASCII'sMSX-DOS2 Tools forMSX-DOS version 2.[8]
InPowerShell,sleep is a predefinedcommand alias for theStart-Sleepcmdlet which serves the same purpose.[9]Microsoft also provides asleep resource kit tool forWindows which can be used inbatch files or thecommand prompt to pause the execution and wait for some time.[10] Another native version is thetimeout command which is part of current versions of Windows.[11]
The command is available as a separate package forMicrosoft Windows as part of theUnxUtils collection ofnativeWin32ports of common GNU Unix-like utilities.[12] Thesleep command has also been ported to theIBM i operating system.[13]
sleepnumber
Wherenumber is an integer[14] number to indicate the time period in seconds. Some implementations supportfloating point numbers.
None.
sleep30Causes the current terminal session to wait 30 seconds.
sleep18000Causes the current terminal session to wait 5 hours
sleep3h;mplayerfoo.mp3Wait 3 hours then play the filefoo.mp3
Note thatsleep 5h30m andsleep 5h 30m are illegal since sleep takes only one value and unit as argument. However,sleep 5.5h (a floating point[15]) is allowed. Consecutive executions of sleep can also be used.
sleep5h;sleep30mSleep 5 hours, then sleep another 30 minutes.
TheGNU Project's implementation of sleep (part ofcoreutils) allows the user to pass an arbitrary floating point[15] or multiple arguments, thereforesleep 5h 30m (a space separating hours and minutes is needed) will work on any system which uses GNU sleep, includingLinux.
Possible uses forsleep include scheduling tasks and delaying execution to allow a process to start, or waiting until a shared network connection most likely has few users towget a large file.
sleep – Shell and Utilities Reference,The Single UNIX Specification, Version 5 fromThe Open Groupsleep(1) – FreeBSD General CommandsManualsleep – Shell and Utilities Reference,The Single UNIX Specification, Version 5 fromThe Open Groupsleep(1) – Plan 9 Programmer's Manual, Volume 1sleep(1) – Inferno General commandsManual