sleep (command)
GPLv2 Plan 9: MIT License |
In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time.
Overview
The sleep instruction suspends the calling process for at least the specified number of seconds (the default), minutes, hours or days.
sleep
for
The version of sleep
bundled in
A sleep
command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.[8]
In
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.[10] Another native version is the timeout
command which is part of current versions of Windows.[11]The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[12] The sleep command has also been ported to the IBM i operating system.[13]
Usage
sleep number
Where number is an integer
Options
None.
Examples
sleep 30
Causes the current terminal session to wait 30 seconds.
sleep 18000
Causes the current terminal session to wait 5 hours
GNU sleep
sleep 3h ; mplayer foo.mp3
Wait 3 hours then play the file 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[15]) is allowed. Consecutive executions of sleep can also be used.
sleep 5h; sleep 30m
Sleep 5 hours, then sleep another 30 minutes.
The
sleep 5h 30m
(a space separating hours and minutes is needed) will work on any system which uses GNU sleep, including LinuxPossible 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
References
- The Single UNIX Specification, Version 4 from The Open Group
- ^ FreeBSD General Commands Manual –
- ^ "sleep(1): delay for specified amount of time - Linux man page". linux.die.net.
- 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.
- ^ "Download Windows Server 2003 Resource Kit Tools from Official Microsoft Download Center". Microsoft. Archived from the original on 2019-06-11. Retrieved 2018-08-10.
- ^ "Timeout". docs.microsoft.com.
- ^ "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.
- ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Retrieved 2020-09-05.
- ^ "sleep(3): sleep for specified number of seconds - Linux man page". linux.die.net. Retrieved 19 April 2018.
- ^ a b "GNU Coreutils: sleep invocation". www.gnu.org. Retrieved 19 April 2018.
External links
- The Single UNIX Specification, Version 4 from The Open Group
– Shell and Utilities Reference,
- Plan 9 Programmer's Manual, Volume 1 –
- Inferno General commands Manual –