I want R to shutdown my computer after my (extensive) simulation and saving results, is this possible?
From the Start menu, open the Run dialog box or you can Press the "Window + R" key to open the RUN window. Type "shutdown -s -t <number in seconds>" and press Enter Key. For example, if you want to shut down your PC/laptop after 10 minutes then, type: shutdown -s -t 600.
To create a shutdown timer manually, open Command Prompt and type the command shutdown -s -t XXXX. The "XXXX" should be the time in seconds you want to elapse before the computer shuts down. For instance, if you want the computer to shut down in 2 hours, the command should look like shutdown -s -t 7200.
Yes, look at the function shutdown
in the package fun
.
The flags for system command shutdown
depends on your operating system, the function simply calls the appropriately flagged command.
fun::shutdown
function (wait = 0)
{
Sys.sleep(wait)
ifelse(.Platform$OS.type == "windows", shell("shutdown -s -t 0"),
system("shutdown -h now"))
}
R can send commands to the system with ?system
, and so whatever is required for Windows can be done with that:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/shutdown.mspx?mfr=true
R has a .Last()
function controlled by quit()
(or q()
) with its runLast
argument, so this is where you would send the shutdown commands via system
, so that it occurs after quitting R. Saving objects with R is done with save
or save.image
, though there is a default to save as well with quit()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With