# Sleep (command)

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Sleep_(command)
> Markdown URL: https://mediated.wiki/source/Sleep_(command).md
> Source: https://en.wikipedia.org/wiki/Sleep_(command)
> Source revision: 1336335442
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Unix command}}
{{lowercase}}
{{Infobox software
| name                   = sleep
| logo                   = 
| screenshot             = Sleepunix.png
| screenshot size        = 
| caption                = The {{code|sleep}} command
| developer              = [AT&T Bell Laboratories](/source/AT%26T_Bell_Laboratories), [Microsoft](/source/Microsoft), [Microware](/source/Microware), Trane Francks
| released               = {{Start date and age|1973|11}}
| latest release version = 
| latest release date    = 
| programming language   = [C](/source/C_(programming_language))
| operating system       = [Unix](/source/Unix), [Unix-like](/source/Unix-like), [V](/source/V_(operating_system)), [Plan 9](/source/Plan_9_from_Bell_Labs), [Inferno](/source/Inferno_(operating_system)), [OS-9](/source/OS-9), [MSX-DOS](/source/MSX-DOS), [FreeDOS](/source/FreeDOS), [Windows](/source/Microsoft_Windows), [KolibriOS](/source/KolibriOS), [IBM i](/source/IBM_i)
| platform               = [Cross-platform](/source/Cross-platform)
| genre                  = [Command](/source/Command_(computing))
| license                = [coreutils](/source/coreutils): [GPLv3+](/source/GPLv3%2B)<br />FreeDOS: [GPLv2](/source/GPLv2)<br />Plan 9: [MIT License](/source/MIT_License)
| website                = 
}}
In [computing](/source/computing), '''sleep''' is a [command](/source/command_(computing)) in [Unix](/source/Unix), [Unix-like](/source/Unix-like) and other [operating system](/source/operating_system)s that [suspends](/source/Sleep_(system_call)) program execution for a specified time.

==Overview==
The sleep instruction suspends the calling [process](/source/process_(computing)) for at least the specified number of seconds (the default), minutes, hours or days.

{{code|sleep}} for [Unix-like](/source/Unix-like) systems is part of the [X/Open](/source/X%2FOpen) Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and the [Single Unix Specification](/source/Single_Unix_Specification).<ref>{{man|cu|sleep|SUS}}</ref> It first appeared in [Version 4 Unix](/source/Ancient_Unix).<ref>{{man|1|sleep|FreeBSD}}</ref>

The version of <code>sleep</code> bundled in [GNU](/source/GNU) [coreutils](/source/coreutils) was written by Jim Meyering and Paul Eggert.<ref>{{Cite web|url=https://linux.die.net/man/1/sleep|title=sleep(1): delay for specified amount of time - Linux man page|website=linux.die.net|access-date=2019-02-28|archive-date=2007-07-12|archive-url=https://web.archive.org/web/20070712184450/https://linux.die.net/man/1/sleep|url-status=live}}</ref> The command is also available in the [OS-9](/source/OS-9) shell,<ref>{{cite book|author=Paul S. Dayan|year=1992|title=The OS-9 Guru - 1 : The Facts|publisher=Galactic Industrial Limited|isbn=0-9519228-0-7}}</ref> in the [KolibriOS](/source/KolibriOS) Shell,<ref>{{Cite web|url=http://wiki.kolibrios.org/wiki/Shell|title=Shell - KolibriOS wiki|website=wiki.kolibrios.org|access-date=2019-03-25|archive-date=2019-02-11|archive-url=https://web.archive.org/web/20190211231827/http://wiki.kolibrios.org/wiki/Shell|url-status=live}}</ref> and part of the [FreeDOS](/source/FreeDOS) ''Package group Utilities''.<ref>{{Cite web|url=http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-util.html|title=ibiblio.org FreeDOS Group -- Utilities|website=www.ibiblio.org|access-date=2018-11-16|archive-date=2018-09-30|archive-url=https://web.archive.org/web/20180930110109/http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-util.html|url-status=live}}</ref> The FreeDOS version was developed by Trane Francks and is licensed under the [GPL](/source/GNU_General_Public_License).<ref>{{Cite web|url=http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/sleep.html|title=ibiblio.org FreeDOS Package -- sleep (Unix-like)|website=www.ibiblio.org|access-date=2018-08-10|archive-date=2018-07-07|archive-url=https://web.archive.org/web/20180707064423/http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/sleep.html|url-status=live}}</ref>

A <code>sleep</code> command is also part of [ASCII](/source/ASCII_Corporation)'s ''MSX-DOS2 Tools'' for [MSX-DOS](/source/MSX-DOS) version 2.<ref>{{Cite web|url=https://archive.org/details/MSXDOS2TOOLS|title=MSX-DOS2 Tools User's Manual - MSX-DOS2 TOOLS ユーザーズマニュアル|date=April 1, 1993|via=Internet Archive}}</ref>

In [PowerShell](/source/PowerShell), <code>sleep</code> is a predefined [command alias](/source/Alias_(command)) for the <code>Start-Sleep</code> [cmdlet](/source/cmdlet) which serves the same purpose.<ref>{{Cite web|url=https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/start-sleep|title=Start-Sleep (Microsoft.PowerShell.Utility) - PowerShell|website=docs.microsoft.com}}</ref> [Microsoft](/source/Microsoft) also provides a <code>sleep</code> resource kit tool for [Windows](/source/Microsoft_Windows) which can be used in [batch file](/source/batch_file)s or the [command prompt](/source/cmd.exe) to pause the execution and wait for some time.<ref>{{Cite web |url=https://www.microsoft.com/en-us/download/details.aspx?id=17657 |title=Download Windows Server 2003 Resource Kit Tools from Official Microsoft Download Center |website=[Microsoft](/source/Microsoft) |access-date=2018-08-10 |archive-date=2019-06-11 |archive-url=https://web.archive.org/web/20190611201442/http://www.microsoft.com/en-us/download/details.aspx?id=17657 |url-status=dead }}</ref> Another native version is the <code>timeout</code> command which is part of current versions of Windows.<ref>{{Cite web|url=https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc754891(v=ws.11)|title=Timeout|website=docs.microsoft.com|access-date=2020-09-13|archive-date=2020-08-06|archive-url=https://web.archive.org/web/20200806200456/https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc754891(v%3Dws.11)|url-status=live}}</ref>

The command is available as a separate package for [Microsoft Windows](/source/Microsoft_Windows) as part of the [UnxUtils](/source/UnxUtils) collection of [native](/source/Native_(computing)) [Win32](/source/Windows_API) [ports](/source/porting) of common GNU Unix-like utilities.<ref>{{Cite web|url=https://unxutils.sourceforge.net/|title=Native Win32 ports of some GNU utilities|website=unxutils.sourceforge.net|access-date=2025-08-11|archive-date=2006-02-09|archive-url=https://web.archive.org/web/20060209022842/http://unxutils.sourceforge.net/|url-status=live}}</ref> The {{Mono|sleep}} command has also been ported to the [IBM i](/source/IBM_i) operating system.<ref>{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=[IBM](/source/IBM) |author-link=IBM |url=https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |access-date=2020-09-05 |archive-date=2020-09-18 |archive-url=https://web.archive.org/web/20200918130823/https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |url-status=live }}</ref>

==Usage==
<syntaxhighlight lang="bash">
 sleep number
</syntaxhighlight>

Where '''number''' is an integer<ref>{{cite web|url=https://linux.die.net/man/3/sleep|title=sleep(3): sleep for specified number of seconds - Linux man page|website=linux.die.net|access-date=19 April 2018|archive-date=6 April 2019|archive-url=https://web.archive.org/web/20190406104546/https://linux.die.net/man/3/sleep|url-status=live}}</ref> number to indicate the time period in seconds. Some implementations support [floating point](/source/floating_point) numbers.

===Options===
None.

==Examples==
<syntaxhighlight lang="bash">
 sleep 30
</syntaxhighlight>
Causes the current terminal session to wait 30 seconds.

<syntaxhighlight lang="bash">
 sleep 18000
</syntaxhighlight>
Causes the current terminal session to wait 5 hours

===GNU sleep===
<syntaxhighlight lang="bash">
 sleep 3h ; mplayer foo.mp3
</syntaxhighlight>

Wait 3 hours then play the file {{mono|foo.mp3}}

Note that <code>sleep 5h30m</code> and <code>sleep 5h 30m</code> are illegal since sleep takes only one value and unit as argument. However, <code>sleep 5.5h</code> (a floating point<ref name="gnu.org">{{cite web|url=http://www.gnu.org/software/coreutils/sleep|title=GNU Coreutils: sleep invocation|website=www.gnu.org|access-date=19 April 2018}}</ref>) is allowed. Consecutive executions of sleep can also be used.

<syntaxhighlight lang="bash">
 sleep 5h; sleep 30m
</syntaxhighlight>

Sleep 5 hours, then sleep another 30 minutes.

The [GNU Project](/source/GNU_Project)'s implementation of sleep (part of [coreutils](/source/coreutils)) allows the user to pass an  arbitrary floating point<ref name="gnu.org"/> or multiple arguments, therefore <code>sleep 5h 30m</code> (a space separating hours and minutes is needed) will work on any system which uses GNU sleep, including [Linux](/source/Linux).

Possible uses for <code>sleep</code> 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](/source/wget) a large file.

==See also==
*[Sleep (system call)](/source/Sleep_(system_call))

==References==
{{Reflist}}

==External links==
{{Wikibooks|Guide to Unix|Commands}}
* {{man|cu|sleep|SUS}}
* {{man|1|sleep|Plan 9}}
* {{man|1|sleep|Inferno}}

{{Unix commands}}
{{Plan 9 commands}}
{{Core Utilities commands}}
{{Windows commands}}

Category:Unix SUS2008 utilities
Category:Unix process- and task-management-related software
Category:Plan 9 commands
Category:Inferno (operating system) commands
Category:IBM i Qshell commands
Category:Microcomputer software

---
Adapted from the Wikipedia article [Sleep (command)](https://en.wikipedia.org/wiki/Sleep_(command)) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Sleep_(command)?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
