xref: /titanic_50/usr/src/man/man1/sleep.1 (revision 0a47c91c895e274dd0990009919e30e984364a8b)
te
Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved Portions
Copyright 1989 AT&T
Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/.
The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text
are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical
and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
This notice shall appear on any product containing this material.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
SLEEP 1 "Nov 20, 2007"
NAME
sleep - suspend execution for an interval
SYNOPSIS

/usr/bin/sleep seconds
"ksh93"

sleep seconds
DESCRIPTION

sleep suspends execution for at least the time in seconds specified by seconds or until a SIGALRM signal is received. The seconds operand can be specified as a floating point number but the actual granularity normally depends on the underlying system.

OPERANDS

The following operands are supported for /usr/bin/sleep and ksh93's sleep built-in command: seconds

A non-negative floating-point number specifying the number of seconds for which to suspend execution. The floating-point number may be specified in all formats required by C99/XPG6, including constants such as "Inf" or "infinite".

"ksh93"

The following operands are supported: time

Specify time in seconds as a floating point number. The actual granularity depends on the underlying system, normally around 1 millisecond.

EXAMPLES

Example 1 Suspending Command Execution

The following example executes a command after a certain amount of time:

example% (sleep 105; command)&

Example 2 Executing a Command Every So Often

The following example executes a command every so often:

example% while true
do
 command
 sleep 37
done

Example 3 Suspend command execution forever (or until a SIGALRM signal is received)

example% sleep Inf

Example 4 Suspending command execution for 0.5 seconds

Suspending command execution for 0.5 seconds using an alternative floating-point representation for the value "0.5"

example% printf "%a\n" 0.5
0x1.0000000000000000000000000000p-01
example% sleep 0x1.0000000000000000000000000000p-01
ENVIRONMENT VARIABLES

See environ(5) for descriptions of the following environment variables that affect the execution of sleep: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH.

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 NOTES).

>0

An error has occurred.

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Committed
Standard See standards(5).
"ksh93"
ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Uncommitted
SEE ALSO

ksh93(1), wait(1), alarm(2), sleep(3C), wait(3UCB), attributes(5), environ(5), standards(5)

NOTES

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

Terminate normally with a zero exit status.

Effectively ignore the signal.

The sleep utility takes the standard action for all other signals.

The behavior for input values such as "NaN" (not-a-number) or negative values is undefined.