1SLEEP(1P) POSIX Programmer's Manual SLEEP(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 sleep - suspend execution for an interval
13
15 sleep time
16
18 The sleep utility shall suspend execution for at least the integral
19 number of seconds specified by the time operand.
20
22 None.
23
25 The following operand shall be supported:
26
27 time A non-negative decimal integer specifying the number of seconds
28 for which to suspend execution.
29
30
32 Not used.
33
35 None.
36
38 The following environment variables shall affect the execution of
39 sleep:
40
41 LANG Provide a default value for the internationalization variables
42 that are unset or null. (See the Base Definitions volume of
43 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
44 ables for the precedence of internationalization variables used
45 to determine the values of locale categories.)
46
47 LC_ALL If set to a non-empty string value, override the values of all
48 the other internationalization variables.
49
50 LC_CTYPE
51 Determine the locale for the interpretation of sequences of
52 bytes of text data as characters (for example, single-byte as
53 opposed to multi-byte characters in arguments).
54
55 LC_MESSAGES
56 Determine the locale that should be used to affect the format
57 and contents of diagnostic messages written to standard error.
58
59 NLSPATH
60 Determine the location of message catalogs for the processing of
61 LC_MESSAGES .
62
63
65 If the sleep utility receives a SIGALRM signal, one of the following
66 actions shall be taken:
67
68 1. Terminate normally with a zero exit status.
69
70 2. Effectively ignore the signal.
71
72 3. Provide the default behavior for signals described in the ASYNCHRO‐
73 NOUS EVENTS section of Utility Description Defaults . This could
74 include terminating with a non-zero exit status.
75
76 The sleep utility shall take the standard action for all other signals.
77
79 Not used.
80
82 The standard error shall be used only for diagnostic messages.
83
85 None.
86
88 None.
89
91 The following exit values shall be returned:
92
93 0 The execution was successfully suspended for at least time sec‐
94 onds, or a SIGALRM signal was received. See the ASYNCHRONOUS
95 EVENTS section.
96
97 >0 An error occurred.
98
99
101 Default.
102
103 The following sections are informative.
104
106 None.
107
109 The sleep utility can be used to execute a command after a certain
110 amount of time, as in:
111
112
113 (sleep 105; command) &
114
115 or to execute a command every so often, as in:
116
117
118 while true
119 do
120 command sleep 37
121 done
122
124 The exit status is allowed to be zero when sleep is interrupted by the
125 SIGALRM signal because most implementations of this utility rely on the
126 arrival of that signal to notify them that the requested finishing time
127 has been successfully attained. Such implementations thus do not dis‐
128 tinguish this situation from the successful completion case. Other
129 implementations are allowed to catch the signal and go back to sleep
130 until the requested time expires or to provide the normal signal termi‐
131 nation procedures.
132
133 As with all other utilities that take integral operands and do not
134 specify subranges of allowed values, sleep is required by this volume
135 of IEEE Std 1003.1-2001 to deal with time requests of up to 2147483647
136 seconds. This may mean that some implementations have to make multiple
137 calls to the delay mechanism of the underlying operating system if its
138 argument range is less than this.
139
141 None.
142
144 wait, the System Interfaces volume of IEEE Std 1003.1-2001, alarm(),
145 sleep()
146
148 Portions of this text are reprinted and reproduced in electronic form
149 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
150 -- Portable Operating System Interface (POSIX), The Open Group Base
151 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
152 Electrical and Electronics Engineers, Inc and The Open Group. In the
153 event of any discrepancy between this version and the original IEEE and
154 The Open Group Standard, the original IEEE and The Open Group Standard
155 is the referee document. The original Standard can be obtained online
156 at http://www.opengroup.org/unix/online.html .
157
158
159
160IEEE/The Open Group 2003 SLEEP(1P)