SLEEP(1) User Commands SLEEP(1)

NAME


sleep - suspend execution for an interval

SYNOPSIS


sleep time[suffix]

DESCRIPTION


sleep suspends execution for at least the time in seconds specified by time
or until a SIGALRM signal is received. The time operand can be specified
as a non-negative floating point number but the actual granularity depends
on the underlying system. The time operand may be passed as a decimal or
hexadecimal string. Other floating point values such as Inf or infinity
are also honored.

A single suffix may be applied to the time operand to represent units other
than seconds. Supported suffixes for the suffix operand include:

s Represents time in seconds.

m Represents time in minutes.

h Represents time in hours.

d Represents time in days.

w Represents time in weeks.

y Represents time in years.

The use of suffixes is generally not portable to other systems.

Signals


If the sleep program receives a signal, unless it is the SIGALRM signal, it
will follow with the default signal handling disposition. If such a signal
would interrupt the sleep, then the program may terminate with an error.

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.

>0 An error has occurred.

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(7) for descriptions of the following environment variables that
affect the execution of sleep: LANG, LC_ALL, LC_MESSAGES, LC_NUMERIC, and
NLSPATH.

INTERFACE STABILITY


Committed

SEE ALSO


wait(1), alarm(2), nanosleep(3C), sleep(3C), environ(7)

illumos September 12, 2019 illumos