sleep - suspend execution for an interval
The sleep utility will suspend execution for at least the integral number of seconds specified by the time operand.
The following operands are supported:
- A non-negative decimal integer specifying the number of seconds for which to suspend execution.
The following environment variables affect the execution of sleep:
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- 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).
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogues for the processing of LC_MESSAGES .
If the sleep utility receives a SIGALRM signal, one of the following actions will be taken:
- Terminate normally with a zero exit status.
- Effectively ignore the signal.
- Provide the default behaviour for signals described in the ASYNCHRONOUS EVENTS section of Utility Description Defaults
. This could include terminating with a non-zero exit status.
The sleep utility will take the standard action for all other signals.
Used only for diagnostic messages.
The following exit values are returned:
- The execution was successfully suspended for at least time seconds, or a SIGALRM signal was received (see the ASYNCHRONOUS EVENTS section).
- An error occurred.
The sleep utility can be used to execute a command after a certain amount of time, as in:
(sleep 105; command) &
or to execute a command every so often, as in:
while true do command sleep 37 done
wait, the XSH specification description of alarm(), sleep().