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 sec‐
28 onds for which to suspend execution.
29
31 Not used.
32
34 None.
35
37 The following environment variables shall affect the execution of
38 sleep:
39
40 LANG Provide a default value for the internationalization vari‐
41 ables that are unset or null. (See the Base Definitions vol‐
42 ume of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
43 ables for the precedence of internationalization variables
44 used to determine the values of locale categories.)
45
46 LC_ALL If set to a non-empty string value, override the values of
47 all the other internationalization variables.
48
49 LC_CTYPE Determine the locale for the interpretation of sequences of
50 bytes of text data as characters (for example, single-byte as
51 opposed to multi-byte characters in arguments).
52
53 LC_MESSAGES
54 Determine the locale that should be used to affect the format
55 and contents of diagnostic messages written to standard
56 error.
57
58 NLSPATH Determine the location of message catalogs for the processing
59 of LC_MESSAGES.
60
62 If the sleep utility receives a SIGALRM signal, one of the following
63 actions shall be taken:
64
65 1. Terminate normally with a zero exit status.
66
67 2. Effectively ignore the signal.
68
69 3. Provide the default behavior for signals described in the ASYNCHRO‐
70 NOUS EVENTS section of Section 1.4, Utility Description Defaults.
71 This could include terminating with a non-zero exit status.
72
73 The sleep utility shall take the standard action for all other signals.
74
76 Not used.
77
79 The standard error shall be used only for diagnostic messages.
80
82 None.
83
85 None.
86
88 The following exit values shall be returned:
89
90 0 The execution was successfully suspended for at least time sec‐
91 onds, or a SIGALRM signal was received. See the ASYNCHRONOUS
92 EVENTS section.
93
94 >0 An error occurred.
95
97 Default.
98
99 The following sections are informative.
100
102 None.
103
105 The sleep utility can be used to execute a command after a certain
106 amount of time, as in:
107
108
109 (sleep 105; command) &
110
111 or to execute a command every so often, as in:
112
113
114 while true
115 do
116 command
117 sleep 37
118 done
119
121 The exit status is allowed to be zero when sleep is interrupted by the
122 SIGALRM signal because most implementations of this utility rely on the
123 arrival of that signal to notify them that the requested finishing time
124 has been successfully attained. Such implementations thus do not dis‐
125 tinguish this situation from the successful completion case. Other
126 implementations are allowed to catch the signal and go back to sleep
127 until the requested time expires or to provide the normal signal termi‐
128 nation procedures.
129
130 As with all other utilities that take integral operands and do not
131 specify subranges of allowed values, sleep is required by this volume
132 of POSIX.1‐2017 to deal with time requests of up to 2147483647 seconds.
133 This may mean that some implementations have to make multiple calls to
134 the delay mechanism of the underlying operating system if its argument
135 range is less than this.
136
138 None.
139
141 wait
142
143 The Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment
144 Variables
145
146 The System Interfaces volume of POSIX.1‐2017, alarm(), sleep()
147
149 Portions of this text are reprinted and reproduced in electronic form
150 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
151 table Operating System Interface (POSIX), The Open Group Base Specifi‐
152 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
153 Electrical and Electronics Engineers, Inc and The Open Group. In the
154 event of any discrepancy between this version and the original IEEE and
155 The Open Group Standard, the original IEEE and The Open Group Standard
156 is the referee document. The original Standard can be obtained online
157 at http://www.opengroup.org/unix/online.html .
158
159 Any typographical or formatting errors that appear in this page are
160 most likely to have been introduced during the conversion of the source
161 files to man page format. To report such errors, see https://www.ker‐
162 nel.org/doc/man-pages/reporting_bugs.html .
163
164
165
166IEEE/The Open Group 2017 SLEEP(1P)