# Sys.sleep

0th

Percentile

##### Suspend Execution for a Time Interval

Suspend execution of R expressions for a specified time interval.

Keywords
utilities
##### Usage
Sys.sleep(time)
##### Arguments
time

The time interval to suspend execution for, in seconds.

##### Details

Using this function allows R to temporarily be given very low priority and hence not to interfere with more important foreground tasks. A typical use is to allow a process launched from R to set itself up and read its input files before R execution is resumed.

The intention is that this function suspends execution of R expressions but wakes the process up often enough to respond to GUI events, typically every half second. It can be interrupted (e.g.by Ctrl-C or Esc at the R console).

There is no guarantee that the process will sleep for the whole of the specified interval (sleep might be interrupted), and it may well take slightly longer in real time to resume execution.

time must be non-negative (and not NA nor NaN): Inf is allowed (and might be appropriate if the intention is to wait indefinitely for an interrupt). The resolution of the time interval is system-dependent, but will normally be 20ms or better. (On modern Unix-alikes it will be better than 1ms.)

##### Value

Invisible NULL.

##### Note

Despite its name, this is not currently implemented using the sleep system call (although on Windows it does make use of Sleep).

• Sys.sleep
##### Examples
library(base) # NOT RUN { testit <- function(x) { p1 <- proc.time() Sys.sleep(x) proc.time() - p1 # The cpu usage should be negligible } testit(3.7) # } 
Documentation reproduced from package base, version 3.6.1, License: Part of R 3.6.1

### Community examples

Looks like there are no examples yet.