sleep (command)

In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time.

sleep
The sleep command
Developer(s)AT&T Bell Laboratories, Microsoft, Microware, Trane Francks
Initial releaseNovember 1973 (1973-11)
Operating systemUnix, Unix-like, V, Plan 9, Inferno, OS-9, MSX-DOS, FreeDOS, Windows, KolibriOS
TypeCommand
Licensecoreutils: GPLv3+
FreeDOS: GPLv2

Overview

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.[1] It first appeared in Version 4 Unix.[2]

The version of sleep bundled in GNU coreutils was written by Jim Meyering and Paul Eggert.[3] The command is also available in the OS-9 shell,[4] in the KolibriOS Shell,[5] and part of the FreeDOS Package group Utilities.[6] The FreeDOS version was developed by Trane Francks and is licensed under the GPL.[7]

A sleep command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.[8]

In Windows PowerShell, sleep is a predefined command alias for the Start-Sleep cmdlet which serves the same purpose.[9] 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.[10] Another native version is the timeout command which is part of current versions of Windows.[11]

Usage

 sleep number

Where number is an integer[12] number to indicate the time period in seconds. Some implementations support floating point numbers.

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 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[13]) 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[13] 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.

gollark: There's a RISC-V one. ESP-C3 or something.
gollark: 1. buy ESP322. load HTTP server code onto it3. configure WiFi4. you are done
gollark: Of course.
gollark: They generally run at about 10% utilization at most doing things like overly extensive self-monitoring, whatever Gitea does, and encoding outbound OIR™ audio streams.
gollark: As such, you can reduce your costs by using the osmarks.net servers, which can idle constantly while serving multiple websites at once.

See also

References

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.