The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

sleep - suspend execution for an interval

 SYNOPSIS



sleep time

 DESCRIPTION

The sleep utility will suspend execution for at least the integral number of seconds specified by the time operand.

 OPTIONS

None.

 OPERANDS

The following operands are supported:
time
A non-negative decimal integer specifying the number of seconds for which to suspend execution.

 STDIN

Not used.

 INPUT FILES

None.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of sleep:
LANG
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.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation 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).
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 catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

If the sleep utility receives a SIGALRM signal, one of the following actions will be taken:

  1. Terminate normally with a zero exit status.

  2. Effectively ignore the signal.

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

 STDOUT

Not used.

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

None.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

The following exit values are returned:
0
The execution was successfully suspended for at least time seconds, or a SIGALRM signal was received (see the ASYNCHRONOUS EVENTS section).
>0
An error occurred.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

None.

 EXAMPLES

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

 FUTURE DIRECTIONS

None.

 SEE ALSO

wait, the XSH specification description of alarm(), sleep().

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]