|Developer(s)||AT&T Bell Laboratories, Microsoft, Microware, Trane Francks|
|Initial release||November 1973|
|Operating system||Unix, Unix-like, V, Plan 9, Inferno, OS-9, MSX-DOS, FreeDOS, Windows, KolibriOS, IBM i|
The sleep instruction suspends the calling process for at least the specified number of seconds (the default), minutes, hours or days.
sleep for Unix-like systems is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and the Single Unix Specification. It first appeared in Version 4 Unix.
The version of
sleep bundled in GNU coreutils was written by Jim Meyering and Paul Eggert. The command is also available in the OS-9 shell, in the KolibriOS Shell, and part of the FreeDOS Package group Utilities. The FreeDOS version was developed by Trane Francks and is licensed under the GPL.
sleep is a predefined command alias for the
Start-Sleep cmdlet which serves the same purpose. 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. Another native version is the
timeout command which is part of current versions of Windows.
Causes the current terminal session to wait 30 seconds.
Causes the current terminal session to wait 5 hours
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) 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 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.
- The Single UNIX Specification, Issue 7 from The Open Group – Commands & Utilities Reference,
- FreeBSD General Commands Manual –
- "sleep(1): delay for specified amount of time - Linux man page". linux.die.net.
- Paul S. Dayan (1992). The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
- "Shell - KolibriOS wiki". wiki.kolibrios.org.
- "ibiblio.org FreeDOS Group -- Utilities". www.ibiblio.org.
- "ibiblio.org FreeDOS Package -- sleep (Unix-like)". www.ibiblio.org.
- "MSX-DOS2 Tools User's Manual - MSX-DOS2 TOOLS ユーザーズマニュアル". April 1, 1993 – via Internet Archive.
- "Start-Sleep (Microsoft.PowerShell.Utility) - PowerShell". docs.microsoft.com.
- [dead link]
- "Timeout". docs.microsoft.com.
- IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). Retrieved 2020-09-05.
- "sleep(3): sleep for specified number of seconds - Linux man page". linux.die.net. Retrieved 19 April 2018.
- "GNU Coreutils: sleep invocation". www.gnu.org. Retrieved 19 April 2018.
|The Wikibook Guide to Unix has a page on the topic of: Commands|