Sleep (command)

Last updated • 2 min readFrom Wikipedia, The Free Encyclopedia
sleep
Developer(s) AT&T Bell Laboratories, Microsoft, Microware, Trane Francks
Initial releaseNovember 1973;49 years ago (1973-11)
Written in C
Operating system Unix, Unix-like, V, Plan 9, Inferno, OS-9, MSX-DOS, FreeDOS, Windows, KolibriOS, IBM i
Platform Cross-platform
Type Command
License coreutils: GPLv3+
FreeDOS: 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.

Contents

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 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]

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 [14] 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 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 GNU Project's implementation of sleep (part of coreutils) allows the user to pass an arbitrary floating point [15] 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.

See also

Related Research Articles

grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command g/re/p, which has the same effect. grep was originally developed for the Unix operating system, but later available for all Unix-like systems and some others such as OS-9.

uniq is a utility command on Unix, Plan 9, Inferno, and Unix-like operating systems which, when fed a text file or standard input, outputs the text with adjacent identical lines collapsed to one, unique line of text.

ls Command to list files and directories in Unix and Unix-like operating systems

In computing, ls is a command to list computer files and directories in Unix and Unix-like operating systems. It is specified by POSIX and the Single UNIX Specification.

mkdir Directory creation command on various operating systems

The mkdir command in the Unix, DOS, DR FlexOS, IBM OS/2, Microsoft Windows, and ReactOS operating systems is used to make a new directory. It is also available in the EFI shell and in the PHP scripting language. In DOS, OS/2, Windows and ReactOS, the command is often abbreviated to md.

pwd Directory information command on various operating systems

In Unix-like and some other operating systems, the pwd command writes the full pathname of the current working directory to the standard output.

uname Standard UNIX utility that prints name and other details about the machine

uname is a computer program in Unix and Unix-like computer operating systems that prints the name, version and other details about the current machine and the operating system running on it.

ln (Unix) Unix file management utility

The ln command is a standard Unix command utility used to create a hard link or a symbolic link (symlink) to an existing file or directory. The use of a hard link allows multiple filenames to be associated with the same file since a hard link points to the inode of a given file, the data of which is stored on disk. On the other hand, symbolic links are special files that refer to other files by name.

In computing, rmdir is a command which will remove an empty directory on various operating systems.

In computing, touch is a command used to update the access date and/or modification date of a computer file or directory. It is included in Unix and Unix-like operating systems, TSC's FLEX, Digital Research/Novell DR DOS, the AROS shell, the Microware OS-9 shell, and ReactOS. The command is also available for FreeDOS and Microsoft Windows.

tr (Unix) Unix text formatting utility

tr is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. It is an abbreviation of translate or transliterate, indicating its operation of replacing or removing specific characters in its input data set.

wc (Unix) Unix command utility

wc is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow.

cmp (Unix)

In computing, cmp is a command-line utility on Unix and Unix-like operating systems that compares two files of any type and writes the results to the standard output. By default, cmp is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported. The command is also available in the OS-9 shell.

rm (Unix) Unix command utility

rm is a basic command on Unix and Unix-like operating systems used to remove objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets, similar to the del command in MS-DOS, OS/2, and Microsoft Windows. The command is also available in the EFI shell.

exit (command)

In computing, exit is a command used in many operating system command-line shells and scripting languages.

more (command) Terminal pager available on various operating systems

In computing, more is a command to view the contents of a text file one screen at a time. It is available on Unix and Unix-like systems, DOS, Digital Research FlexOS, IBM/Toshiba 4690 OS, IBM OS/2, Microsoft Windows and ReactOS. Programs of this sort are called pagers. more is a very basic pager, originally allowing only forward navigation through a file, though newer implementations do allow for limited backward movement.

tail is a program available on Unix, Unix-like systems, FreeDOS and MSX-DOS used to display the tail end of a text file or piped data.

In computing, tee is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input. It is primarily used in conjunction with pipes and filters. The command is named after the T-splitter used in plumbing.

sort (Unix) Standard UNIX utility

In computing, sort is a standard command line program of Unix and Unix-like operating systems, that prints the lines of its input or concatenation of all files listed in its argument list in sorted order. Sorting is done based on one or more sort keys extracted from each line of input. By default, the entire input is taken as sort key. Blank space is the default field separator. The command supports a number of command-line options that can vary by implementation. For instance the "-r" flag will reverse the sort order.

In computing, which is a command for various operating systems used to identify the location of executables. The command is available in Unix and Unix-like systems, the AROS shell, for FreeDOS and for Microsoft Windows. The functionality of the which command is similar to some implementations of the type command. POSIX specifies a command named command that also covers this functionality.

help (command) Command in various command line shells

In computing, help is a command in various command line shells such as COMMAND.COM, cmd.exe, Bash, qshell, 4DOS/4NT, Windows PowerShell, Singularity shell, Python, MATLAB and GNU Octave. It provides online information about available commands and the shell environment.

References

  1. sleep   Shell and Utilities Reference, The Single UNIX Specification , Version 4 from The Open Group
  2. sleep(1)    FreeBSD General Commands Manual
  3. "sleep(1): delay for specified amount of time - Linux man page". linux.die.net.
  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.
  6. "ibiblio.org FreeDOS Group -- Utilities". www.ibiblio.org.
  7. "ibiblio.org FreeDOS Package -- sleep (Unix-like)". www.ibiblio.org.
  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 from the original on 2019-06-11. Retrieved 2018-08-10.
  11. "Timeout". docs.microsoft.com.
  12. "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.
  13. IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM . Retrieved 2020-09-05.
  14. "sleep(3): sleep for specified number of seconds - Linux man page". linux.die.net. Retrieved 19 April 2018.
  15. 1 2 "GNU Coreutils: sleep invocation". www.gnu.org. Retrieved 19 April 2018.