SLEEP(1) BSD Reference Manual SLEEP(1)
NAME
sleep - suspend execution for an interval of time
SYNOPSIS
sleep time [...]
DESCRIPTION
The sleep utility suspends execution for the amount of time specified by
its operands.
sleep is commonly used to delay proceeding within a series of commands.
Another use is to schedule the execution of other commands, but sleep
will not take changes to the system clock that occur during its execution
into account (it sleeps "for time seconds", not "until a specific time");
it also uses the simplified notion of a day having 86400 seconds.
Each time operand (multiple operands are added together to form a total
amount of time to sleep) must be comprised of a positive number, which
may contain a decimal fraction, and optionally a suffix letter denoting a
scaling factor. The scaling factors supported are as follows:
s seconds (1); default
m minutes (60)
h hours (3600)
d days (86400)
EXAMPLES
Monitor the growth of a file without consuming too many resources:
while sleep 5; do
ls -l file
done
Wait an half hour before running the script command_file (see also the
at(1) utility):
(sleep 1800; sh command_file >errors 2>&1) &
DIAGNOSTICS
The sleep utility exits 0 on success or upon receipt of SIGALRM, and >0
if an error occurs.
SEE ALSO
at(1), select(2)
STANDARDS
The sleep utility conforms to IEEE Std 1003.1-2008 ("POSIX.1").
The handling of fractional arguments is provided as an extension to the
specification. The handling of multiple arguments and an optional suffix
is provided for compatibility with GNU coreutils' sleep utility.
AUTHORS
mirabilos <m@mirbsd.org>
CAVEATS
sleep parses fractional arguments up to six digits after the period; any
further digits are silently ignored. Suffix scaling is performed after-
wards and so can deviate up to 86.4 ms.
The underlying system call accepts input to the microsecond but may be
using a clock with coarse granularity, which affects the accuracy of the
time actually slept; the time utility is known to use a much less accu-
rate timer, but compiling the sleep utility with -DDEBUG will show that
it always sleeps for at least the requested time.
MirBSD January 23, 2021 1