xref: /illumos-gate/usr/src/man/man1/sleep.1 (revision b69c34dad3717624ff6b4f32b71014ee05b6a678)
1.\"
2.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3.\" permission to reproduce portions of its copyrighted documentation.
4.\" Original documentation from The Open Group can be obtained online at
5.\" http://www.opengroup.org/bookstore/.
6.\"
7.\" The Institute of Electrical and Electronics Engineers and The Open
8.\" Group, have given us permission to reprint portions of their
9.\" documentation.
10.\"
11.\" In the following statement, the phrase ``this text'' refers to portions
12.\" of the system documentation.
13.\"
14.\" Portions of this text are reprinted and reproduced in electronic form
15.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16.\" Standard for Information Technology -- Portable Operating System
17.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20.\" between these versions and the original IEEE and The Open Group
21.\" Standard, the original IEEE and The Open Group Standard is the referee
22.\" document.  The original Standard can be obtained online at
23.\" http://www.opengroup.org/unix/online.html.
24.\"
25.\" This notice shall appear on any product containing this material.
26.\"
27.\" The contents of this file are subject to the terms of the
28.\" Common Development and Distribution License (the "License").
29.\" You may not use this file except in compliance with the License.
30.\"
31.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32.\" or http://www.opensolaris.org/os/licensing.
33.\" See the License for the specific language governing permissions
34.\" and limitations under the License.
35.\"
36.\" When distributing Covered Code, include this CDDL HEADER in each
37.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38.\" If applicable, add the following below this CDDL HEADER, with the
39.\" fields enclosed by brackets "[]" replaced with your own identifying
40.\" information: Portions Copyright [yyyy] [name of copyright owner]
41.\"
42.\"
43.\" Copyright 1989 AT&T
44.\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
45.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
46.\" Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved  Portions
47.\" Copyright 2019 Robert Mustacchi
48.\"
49.Dd September 12, 2019
50.Dt SLEEP 1
51.Os
52.Sh NAME
53.Nm sleep
54.Nd suspend execution for an interval
55.Sh SYNOPSIS
56.Nm sleep
57.Ar time[suffix]
58.Sh DESCRIPTION
59.Nm
60suspends execution for at least the time in seconds specified by
61.Ar time
62or until a
63.Dv SIGALRM
64signal is received.
65The
66.Ar time
67operand can be specified as a non-negative floating point number but the
68actual granularity depends on the underlying system.
69The
70.Ar time
71operand may be passed as a decimal or hexadecimal string.
72Other floating point values such as Inf or infinity are also honored.
73.Pp
74A single suffix may be applied to the
75.Ar time
76operand to represent units other than seconds.
77Supported suffixes for the
78.Ar suffix
79operand include:
80.Bl -tag -offset indent -width 6n
81.It Sy s
82Represents time in seconds.
83.It Sy m
84Represents time in minutes.
85.It Sy h
86Represents time in hours.
87.It Sy d
88Represents time in days.
89.It Sy w
90Represents time in weeks.
91.It Sy y
92Represents time in years.
93.El
94.Pp
95The use of suffixes is generally not portable to other systems.
96.Ss Signals
97If the
98.Nm
99program receives a signal, unless it is the
100.Dv SIGALRM
101signal, it will follow with the default signal handling disposition.
102If such a signal would interrupt the sleep, then the program may
103terminate with an error.
104.Sh EXIT STATUS
105The following exit values are returned:
106.Bl -inset
107.It Sy 0
108The execution was successfully suspended for at least
109.Ar time
110seconds, or a
111.Dv SIGALRM
112signal was received.
113.It Sy >0
114An error has occurred.
115.El
116.Sh EXAMPLES
117.Sy Example 1
118Suspending Command Execution
119.Pp
120The following example executes a command after a certain amount of time:
121.Bd -literal -offset indent
122example% \fB(sleep 105; \fIcommand\fR)&\fR
123.Ed
124.Pp
125.Sy Example 2
126Executing a Command Every So Often
127.Pp
128The following example executes a command every so often:
129.Bd -literal -offset indent
130example% \fBwhile true; do
131        \fIcommand\fR
132        sleep 37
133done\fR
134.Ed
135.Pp
136.Sy Example 3
137Suspend command execution forever
138.Po
139or until a
140.Dv SIGALRM
141signal is received
142.Pc
143.Bd -literal
144example% sleep Inf
145.Ed
146.Pp
147.Sy Example 4
148Suspending command execution for 0.5 seconds
149.Pp
150Suspending command execution for 0.5 seconds using an alternative
151floating-point representation for the value "0.5".
152.Bd -literal
153example% printf "%a\en" 0.5
1540x1.0000000000000000000000000000p-01
155example% sleep 0x1.0000000000000000000000000000p-01
156.Ed
157.Sh ENVIRONMENT VARIABLES
158See
159.Xr environ 5
160for descriptions of the following environment variables
161that affect the execution of
162.Nm :
163.Ev LANG ,
164.Ev LC_ALL ,
165.Ev LC_MESSAGES ,
166.Ev LC_NUMERIC ,
167and
168.Ev NLSPATH .
169.Sh INTERFACE STABILITY
170.Sy Committed
171.Sh SEE ALSO
172.Xr wait 1 ,
173.Xr alarm 2 ,
174.Xr nanosleep 3C ,
175.Xr sleep 3C ,
176.Xr environ 5
177