1SLEEP(P)                   POSIX Programmer's Manual                  SLEEP(P)
2
3
4

NAME

6       sleep - suspend execution for an interval
7

SYNOPSIS

9       sleep time
10

DESCRIPTION

12       The  sleep  utility  shall  suspend execution for at least the integral
13       number of seconds specified by the time operand.
14

OPTIONS

16       None.
17

OPERANDS

19       The following operand shall be supported:
20
21       time   A non-negative decimal integer specifying the number of  seconds
22              for which to suspend execution.
23
24

STDIN

26       Not used.
27

INPUT FILES

29       None.
30

ENVIRONMENT VARIABLES

32       The  following  environment  variables  shall  affect  the execution of
33       sleep:
34
35       LANG   Provide a default value for the  internationalization  variables
36              that  are  unset  or  null.  (See the Base Definitions volume of
37              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
38              ables  for the precedence of internationalization variables used
39              to determine the values of locale categories.)
40
41       LC_ALL If set to a non-empty string value, override the values  of  all
42              the other internationalization variables.
43
44       LC_CTYPE
45              Determine  the  locale  for  the  interpretation of sequences of
46              bytes of text data as characters (for  example,  single-byte  as
47              opposed to multi-byte characters in arguments).
48
49       LC_MESSAGES
50              Determine  the  locale  that should be used to affect the format
51              and contents of diagnostic messages written to standard error.
52
53       NLSPATH
54              Determine the location of message catalogs for the processing of
55              LC_MESSAGES .
56
57

ASYNCHRONOUS EVENTS

59       If  the  sleep  utility receives a SIGALRM signal, one of the following
60       actions shall be taken:
61
62        1. Terminate normally with a zero exit status.
63
64        2. Effectively ignore the signal.
65
66        3. Provide the default behavior for signals described in the ASYNCHRO‐
67           NOUS  EVENTS  section  of Utility Description Defaults . This could
68           include terminating with a non-zero exit status.
69
70       The sleep utility shall take the standard action for all other signals.
71

STDOUT

73       Not used.
74

STDERR

76       The standard error shall be used only for diagnostic messages.
77

OUTPUT FILES

79       None.
80

EXTENDED DESCRIPTION

82       None.
83

EXIT STATUS

85       The following exit values shall be returned:
86
87        0     The execution was successfully suspended for at least time  sec‐
88              onds,  or  a  SIGALRM  signal was received. See the ASYNCHRONOUS
89              EVENTS section.
90
91       >0     An error occurred.
92
93

CONSEQUENCES OF ERRORS

95       Default.
96
97       The following sections are informative.
98

APPLICATION USAGE

100       None.
101

EXAMPLES

103       The sleep utility can be used to execute  a  command  after  a  certain
104       amount of time, as in:
105
106
107              (sleep 105; command) &
108
109       or to execute a command every so often, as in:
110
111
112              while true
113              do
114                  command    sleep 37
115              done
116

RATIONALE

118       The  exit status is allowed to be zero when sleep is interrupted by the
119       SIGALRM signal because most implementations of this utility rely on the
120       arrival of that signal to notify them that the requested finishing time
121       has been successfully attained.  Such implementations thus do not  dis‐
122       tinguish  this  situation  from  the  successful completion case. Other
123       implementations are allowed to catch the signal and go  back  to  sleep
124       until the requested time expires or to provide the normal signal termi‐
125       nation procedures.
126
127       As with all other utilities that take  integral  operands  and  do  not
128       specify  subranges  of allowed values, sleep is required by this volume
129       of IEEE Std 1003.1-2001 to deal with time requests of up to  2147483647
130       seconds.  This may mean that some implementations have to make multiple
131       calls to the delay mechanism of the underlying operating system if  its
132       argument range is less than this.
133

FUTURE DIRECTIONS

135       None.
136

SEE ALSO

138       wait  ,  the System Interfaces volume of IEEE Std 1003.1-2001, alarm(),
139       sleep()
140
142       Portions of this text are reprinted and reproduced in  electronic  form
143       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
144       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
145       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
146       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
147       event of any discrepancy between this version and the original IEEE and
148       The Open Group Standard, the original IEEE and The Open Group  Standard
149       is  the  referee document. The original Standard can be obtained online
150       at http://www.opengroup.org/unix/online.html .
151
152
153
154IEEE/The Open Group                  2003                             SLEEP(P)
Impressum