sleep
sleep EXPR
sleepThis function causes the script to sleep for
EXPR (integer) seconds, or forever if no
EXPR, and returns the number of seconds
slept. It may be interrupted by sending the process a SIGALRM. On some older systems, it may sleep
up to a full second less than what you requested, depending on how it
counts seconds. Most modern systems always sleep the full amount. They
may appear to sleep longer than that, however, because your process
might not be scheduled right away in a busy multitasking system. For
delays of finer granularity than one second, the standard Time::HiRes module provides a usleep function. If available, the select (ready file descriptors) call can also
give you better resolution. You may be able to use syscall to call the
getitimer(2) and setitimer(2)
routines that some Unix systems support. You probably cannot mix
alarm and sleep calls because sleep is often implemented using alarm.
See also the POSIX module’s pause
function.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access