shutdown: Shut down the operating system with the command 'shutdown'

View source: R/shutdown.R

shutdownR Documentation

Shut down the operating system with the command ‘shutdown’

Description

There is a command shutdown in both Windows and Linux, and this function uses it to shut down a computer.

Usage

shutdown(wait = 0)

Arguments

wait

time to wait before shutting down (in seconds); passed to Sys.sleep

Details

After the time wait has passed, R will execute shutdown -s -t 0 (for Windows) or shutdown -h now to shut down the computer.

Value

The status code of system.

Author(s)

Yihui Xie <https://yihui.org>

See Also

system, Sys.sleep

Examples

if (interactive()) {
    # when your code is extremely time-consuming, you may need this function;
    # e.g. you go to sleep, and R is running long computation... complex
    # graphics... and long long computation... at last,
    shutdown()
    # the next day you wake up, 'thank you, R' :)
}

fun documentation built on Feb. 26, 2026, 9:07 a.m.