Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

sleep (command)

From Wikipedia, the free encyclopedia
Unix command
sleep
Thesleep command
DevelopersAT&T Bell Laboratories,Microsoft,Microware, Trane Francks
Initial releaseNovember 1973; 52 years ago (1973-11)
Written inC
Operating systemUnix,Unix-like,V,Plan 9,Inferno,OS-9,MSX-DOS,FreeDOS,Windows,KolibriOS,IBM i
PlatformCross-platform
TypeCommand
Licensecoreutils:GPLv3+
FreeDOS:GPLv2
Plan 9:MIT License

Incomputing,sleep is acommand inUnix,Unix-like and otheroperating systems thatsuspends program execution for a specified time.

Overview

[edit]

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]

Usage

[edit]
sleepnumber

Wherenumber is an integer[14] number to indicate the time period in seconds. Some implementations supportfloating point numbers.

Options

[edit]

None.

Examples

[edit]
sleep30

Causes the current terminal session to wait 30 seconds.

sleep18000

Causes the current terminal session to wait 5 hours

GNU sleep

[edit]
sleep3h;mplayerfoo.mp3

Wait 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;sleep30m

Sleep 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.

See also

[edit]

References

[edit]
  1. ^sleep – Shell and Utilities Reference,The Single UNIX Specification, Version 5 fromThe Open Group
  2. ^sleep(1) – FreeBSD General CommandsManual
  3. ^"sleep(1): delay for specified amount of time - Linux man page".linux.die.net.Archived from the original on 2007-07-12. Retrieved2019-02-28.
  4. ^Paul S. Dayan (1992).The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited.ISBN 0-9519228-0-7.
  5. ^"Shell - KolibriOS wiki".wiki.kolibrios.org.Archived from the original on 2019-02-11. Retrieved2019-03-25.
  6. ^"ibiblio.org FreeDOS Group -- Utilities".www.ibiblio.org.Archived from the original on 2018-09-30. Retrieved2018-11-16.
  7. ^"ibiblio.org FreeDOS Package -- sleep (Unix-like)".www.ibiblio.org.Archived from the original on 2018-07-07. Retrieved2018-08-10.
  8. ^"MSX-DOS2 Tools User's Manual - MSX-DOS2 TOOLS ユーザーズマニュアル". April 1, 1993 – via Internet Archive.
  9. ^"Start-Sleep (Microsoft.PowerShell.Utility) - PowerShell".docs.microsoft.com.
  10. ^"Download Windows Server 2003 Resource Kit Tools from Official Microsoft Download Center".Microsoft. Archived fromthe original on 2019-06-11. Retrieved2018-08-10.
  11. ^"Timeout".docs.microsoft.com.Archived from the original on 2020-08-06. Retrieved2020-09-13.
  12. ^"Native Win32 ports of some GNU utilities".unxutils.sourceforge.net.Archived from the original on 2006-02-09. Retrieved2025-08-11.
  13. ^IBM."IBM System i Version 7.2 Programming Qshell"(PDF).IBM.Archived(PDF) from the original on 2020-09-18. Retrieved2020-09-05.
  14. ^"sleep(3): sleep for specified number of seconds - Linux man page".linux.die.net.Archived from the original on 6 April 2019. Retrieved19 April 2018.
  15. ^ab"GNU Coreutils: sleep invocation".www.gnu.org. Retrieved19 April 2018.

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
File system
Processes
User environment
Text processing
Shell builtins
Networking
Searching
Software development
Miscellaneous
File system
Text utilities
Shell utilities
Ecosystem
Interpreters
Terminals
File system navigation
File management
Archiving
Disk management
Processes
Registry
User environment
File contents
Scripting
Networking
Maintenance and care
Boot management
Software development
Miscellaneous
Retrieved from "https://en.wikipedia.org/w/index.php?title=Sleep_(command)&oldid=1336335442"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp