The sleep command suspends the execution of the process that calls it for a user-defined period of time.
sleep is used mainly in shell scripts to delay the execution of the next command.
Syntax
sleep time |
time The time in seconds after which execution of the process is to resume. |
Error
You have used a negative integer or a non-numeric expression for time. |
Locale
The following environment variables affect the execution of sleep: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example 1
This example makes use of sleep from the command line. You start a background process to remind yourself in 10 minutes (600 seconds) that you need to make a phone call:
|
Example 2
In this example, sleep is used within a shell script named always, which calls the backup program every two minutes:
If you run the always script as a background process, you will only be able to terminate it with kill, not with CTRL+C. |
See also
alarm(), sleep() [4] |